/*1* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.2*3* @APPLE_APACHE_LICENSE_HEADER_START@4*5* Licensed under the Apache License, Version 2.0 (the "License");6* you may not use this file except in compliance with the License.7* You may obtain a copy of the License at8*9* http://www.apache.org/licenses/LICENSE-2.010*11* Unless required by applicable law or agreed to in writing, software12* distributed under the License is distributed on an "AS IS" BASIS,13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14* See the License for the specific language governing permissions and15* limitations under the License.16*17* @APPLE_APACHE_LICENSE_HEADER_END@18*/1920#ifndef __VPROC_H__21#define __VPROC_H__2223#include <sys/cdefs.h>24#include <sys/types.h>25#include <stdarg.h>26#ifdef __APPLE__27#include <Availability.h>28#else29#include "shims/Availability.h"30#endif3132#ifndef VPROC_HAS_TRANSACTIONS33#define VPROC_HAS_TRANSACTIONS34#endif3536__BEGIN_DECLS3738#pragma GCC visibility push(default)3940typedef void * vproc_err_t;4142typedef struct vproc_s * vproc_t;43typedef void * vprocmgr_t;4445const char *vproc_strerror(vproc_err_t r);4647/*!48* @header vproc49*50* Processes have two reference counts associated with them:51*52* Transactions Tracks unfinished work. For example: saving a modified53* document.54* Standby Tracks outstanding callbacks from external subsystems.55*56* Descriptive aliases:57*58* A process with no outstanding transactions is called "clean."59* A process with outstanding transactions is called "dirty."60* A process with no standby work is called "idle."61*62* Sometimes, the operating system needs processes to exit. Unix has two63* primary signals to kill applications:64*65* SIGKILL Not catchable by the application.66* SIGTERM Catchable by the application.67*68* If a process is clean, the operating system is free to SIGKILL it at69* shutdown or logout. This behavior is opt in.70*71* If a process is clean and idle, the operating system may send SIGKILL after72* a application specified timeout. This behavior is opt in.73*74* If a process is dirty and idle, the operating system may send SIGTERM after75* a application specified timeout. This behavior is opt in.76*77*78* launchd jobs should update their property lists accordingly.79*80* We plan to have LaunchServices use private methods to coordinate81* whether GUI applications have opted into this design.82*/8384/*!85* @typedef vproc_transaction_t86*87* @abstract88* An opaque handle used to track outstanding transactions.89*/90typedef struct vproc_transaction_s *vproc_transaction_t;9192/*!93* @function vproc_transaction_begin94*95* @param virtual_proc96* This is meant for future API improvements. Pass NULL for now.97*98* @result99* Returns an opaque handle to be passed to vproc_transaction_end().100*101* @abstract102* Call this API before creating data that needs to be saved via I/O later.103*/104vproc_transaction_t105vproc_transaction_begin(vproc_t virtual_proc) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0);106107/*!108* @function vproc_transaction_end109*110* @param virtual_proc111* This is meant for future API improvements. Pass NULL for now.112*113* @param handle114* The handle previously created with vproc_transaction_begin().115*116* @abstract117* Call this API after the data has either been flushed or otherwise resolved.118*119* @discussion120* Calling this API with the same handle more than once is undefined.121*/122void123vproc_transaction_end(vproc_t virtual_proc, vproc_transaction_t handle) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0);124125/*!126* @typedef vproc_standby_t127*128* @abstract129* An opaque handle used to track outstanding standby requests.130*/131typedef struct vproc_standby_s *vproc_standby_t;132133/*!134* @function vproc_standby_begin135*136* @param virtual_proc137* This is meant for future API improvements. Pass NULL for now.138*139* @result140* Returns an opaque handle to be passed to vproc_standby_end().141*142* @abstract143* Call this API before registering notifications. For example: timers network144* state change, or when monitoring keyboard/mouse events.145*146* @discussion147* This API is undefined and is currently a no-op.148*/149vproc_standby_t150vproc_standby_begin(vproc_t virtual_proc) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_NA);151152/*!153* @function vproc_standby_end154*155* @param virtual_proc156* This is meant for future API improvements. Pass NULL for now.157*158* @param handle159* The handle previously created with vproc_standby_begin().160*161* @abstract162* Call this API when deregistering notifications.163*164* @discussion165* Calling this API with the same handle more than once is undefined.166* This API is undefined and is currently a no-op.167*/168void169vproc_standby_end(vproc_t virtual_proc, vproc_standby_t handle) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_NA);170171#pragma GCC visibility pop172173__END_DECLS174175#endif /* __VPROC_H__ */176177178