UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
locks.h
1 /* locks.h */
2 /* $Id: locks.h,v 1.10 2007/08/30 07:26:58 ibadm Exp $ */
3 
4 /*********************************************************************
5  *
6  * UNIVERS
7  * (C) ООО "ГЕОВЕРС", 2001
8  *
9  * Все права защищены * * Использование, копирование или передача регулируются законами * Российской Федерации "Об авторском праве и смежных правах", "О * правовой охране программ для электронных вычислительных машин и баз * данных" * * Encoding: ISO-8859-5 (GOST) * *********************************************************************/ #ifndef __locks_h #define __locks_h #include <mix/Types.h> #include <mix/wenv.h> #include <mix/misc.h> /*********************************************************************** * * Simple exclusive lock API. * ***********************************************************************/ /** If some lock can't be made due to ERROR__SHARED_REFUSED, given numbers of attempts will be made. */ #define EXCL_LOCK_TRIES 5 /** Between attemps a delay take place (in seconds). */ #define EXCL_LOCK_DELAY 1 /** Between attemps a delay take place (in microseconds). */ #define EXCL_LOCK_DELAY_US 50000 /** Type for identifying the lock. */ typedef Int4 LockId; /** Default value of project id for IPC (see ftok(3C)). Alternative project id lay in VSPIPCID env. variable + 1 */ #define PROCESS_LOCK_IPC_ID 168 /** Number used for building semaphore key using also PROCESS_LOCK_IPC_ID */ #define PROCESS_LOCK_SEM_KEY 1 /** Reasons for process lock due to inter-process and process-exclusive communications. */ typedef enum { plrHardKeyAccess = 0, /**< hard key access is exclusive */ plrSessionManagement, /**< session management operations are exclusive */ plrKeysourcerCell, /**< access to cell with PEP IPC counter */ __plrNumber /**< number of reasons - not a reason truely */ } ProcessLockReason; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** Test lock for existance. Returns TRUE or FALSE. */ Logic LockCheck (LockId lid); /** Make exclusive lock of the file object. In opposition to class FileLock this routine trys to lock an object several times with small delays. */ ErrCode LockResourceExclusive (LockId* plid, const char* path); /** Make process lock for given reason. */ ErrCode LockProcess (LockId* plid, ProcessLockReason reason); /** Register reliable at-exit handler. */ ErrCode LockAtExit (LockId* plid, weAtExitHandlerProc proc); /** Delete given lock of resource. */ ErrCode UnlockResourceById (LockId lid); /** Delete all locks, made by the program. DANGER!!! Use with considerable care and only just before program end! */ void UnlockAllResources (); /* * Special lock supervisor operations. They operate over other * application's locks and may cause unreliable simultaneous access * to the same file/db objects. */ /** Check for locked file object. Do not care about very time dependence of lock state information. Returns TRUE if lock is set and FALSE otherwise. */ Logic CheckLockedResource (const char* path); /** Get list of locks in given directory. */ ErrCode ListLockedResources (const char* dirpath, unsigned* n, STRLIST* list); /** Unlock file object. DANGER! The function doesn't respect living lock. Returns OK if lock was released and error code otherwise. */ ErrCode ReleaseLockedResource (const char* path); /** Unlock all file objects in given directory. DANGER! The function doesn't respect living and sharable locks!. Returns OK if all locks were released and error code otherwise. n contains number of locks which can't be released. Error code matches the last failed release. */ ErrCode ReleaseAllLockedResources (const char* dirpath, unsigned* failed); #ifdef __cplusplus }; #endif /* __cplusplus */ #endif /* locks.h */
10  *
11  * Использование, копирование или передача регулируются законами
12  * Российской Федерации "Об авторском праве и смежных правах", "О * правовой охране программ для электронных вычислительных машин и баз * данных" * * Encoding: ISO-8859-5 (GOST) * *********************************************************************/ #ifndef __locks_h #define __locks_h #include <mix/Types.h> #include <mix/wenv.h> #include <mix/misc.h> /*********************************************************************** * * Simple exclusive lock API. * ***********************************************************************/ /** If some lock can't be made due to ERROR__SHARED_REFUSED, given numbers of attempts will be made. */ #define EXCL_LOCK_TRIES 5 /** Between attemps a delay take place (in seconds). */ #define EXCL_LOCK_DELAY 1 /** Between attemps a delay take place (in microseconds). */ #define EXCL_LOCK_DELAY_US 50000 /** Type for identifying the lock. */ typedef Int4 LockId; /** Default value of project id for IPC (see ftok(3C)). Alternative project id lay in VSPIPCID env. variable + 1 */ #define PROCESS_LOCK_IPC_ID 168 /** Number used for building semaphore key using also PROCESS_LOCK_IPC_ID */ #define PROCESS_LOCK_SEM_KEY 1 /** Reasons for process lock due to inter-process and process-exclusive communications. */ typedef enum { plrHardKeyAccess = 0, /**< hard key access is exclusive */ plrSessionManagement, /**< session management operations are exclusive */ plrKeysourcerCell, /**< access to cell with PEP IPC counter */ __plrNumber /**< number of reasons - not a reason truely */ } ProcessLockReason; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** Test lock for existance. Returns TRUE or FALSE. */ Logic LockCheck (LockId lid); /** Make exclusive lock of the file object. In opposition to class FileLock this routine trys to lock an object several times with small delays. */ ErrCode LockResourceExclusive (LockId* plid, const char* path); /** Make process lock for given reason. */ ErrCode LockProcess (LockId* plid, ProcessLockReason reason); /** Register reliable at-exit handler. */ ErrCode LockAtExit (LockId* plid, weAtExitHandlerProc proc); /** Delete given lock of resource. */ ErrCode UnlockResourceById (LockId lid); /** Delete all locks, made by the program. DANGER!!! Use with considerable care and only just before program end! */ void UnlockAllResources (); /* * Special lock supervisor operations. They operate over other * application's locks and may cause unreliable simultaneous access * to the same file/db objects. */ /** Check for locked file object. Do not care about very time dependence of lock state information. Returns TRUE if lock is set and FALSE otherwise. */ Logic CheckLockedResource (const char* path); /** Get list of locks in given directory. */ ErrCode ListLockedResources (const char* dirpath, unsigned* n, STRLIST* list); /** Unlock file object. DANGER! The function doesn't respect living lock. Returns OK if lock was released and error code otherwise. */ ErrCode ReleaseLockedResource (const char* path); /** Unlock all file objects in given directory. DANGER! The function doesn't respect living and sharable locks!. Returns OK if all locks were released and error code otherwise. n contains number of locks which can't be released. Error code matches the last failed release. */ ErrCode ReleaseAllLockedResources (const char* dirpath, unsigned* failed); #ifdef __cplusplus }; #endif /* __cplusplus */ #endif /* locks.h */
13  * правовой охране программ для электронных вычислительных машин и баз * данных" * * Encoding: ISO-8859-5 (GOST) * *********************************************************************/ #ifndef __locks_h #define __locks_h #include <mix/Types.h> #include <mix/wenv.h> #include <mix/misc.h> /*********************************************************************** * * Simple exclusive lock API. * ***********************************************************************/ /** If some lock can't be made due to ERROR__SHARED_REFUSED, given numbers of attempts will be made. */ #define EXCL_LOCK_TRIES 5 /** Between attemps a delay take place (in seconds). */ #define EXCL_LOCK_DELAY 1 /** Between attemps a delay take place (in microseconds). */ #define EXCL_LOCK_DELAY_US 50000 /** Type for identifying the lock. */ typedef Int4 LockId; /** Default value of project id for IPC (see ftok(3C)). Alternative project id lay in VSPIPCID env. variable + 1 */ #define PROCESS_LOCK_IPC_ID 168 /** Number used for building semaphore key using also PROCESS_LOCK_IPC_ID */ #define PROCESS_LOCK_SEM_KEY 1 /** Reasons for process lock due to inter-process and process-exclusive communications. */ typedef enum { plrHardKeyAccess = 0, /**< hard key access is exclusive */ plrSessionManagement, /**< session management operations are exclusive */ plrKeysourcerCell, /**< access to cell with PEP IPC counter */ __plrNumber /**< number of reasons - not a reason truely */ } ProcessLockReason; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** Test lock for existance. Returns TRUE or FALSE. */ Logic LockCheck (LockId lid); /** Make exclusive lock of the file object. In opposition to class FileLock this routine trys to lock an object several times with small delays. */ ErrCode LockResourceExclusive (LockId* plid, const char* path); /** Make process lock for given reason. */ ErrCode LockProcess (LockId* plid, ProcessLockReason reason); /** Register reliable at-exit handler. */ ErrCode LockAtExit (LockId* plid, weAtExitHandlerProc proc); /** Delete given lock of resource. */ ErrCode UnlockResourceById (LockId lid); /** Delete all locks, made by the program. DANGER!!! Use with considerable care and only just before program end! */ void UnlockAllResources (); /* * Special lock supervisor operations. They operate over other * application's locks and may cause unreliable simultaneous access * to the same file/db objects. */ /** Check for locked file object. Do not care about very time dependence of lock state information. Returns TRUE if lock is set and FALSE otherwise. */ Logic CheckLockedResource (const char* path); /** Get list of locks in given directory. */ ErrCode ListLockedResources (const char* dirpath, unsigned* n, STRLIST* list); /** Unlock file object. DANGER! The function doesn't respect living lock. Returns OK if lock was released and error code otherwise. */ ErrCode ReleaseLockedResource (const char* path); /** Unlock all file objects in given directory. DANGER! The function doesn't respect living and sharable locks!. Returns OK if all locks were released and error code otherwise. n contains number of locks which can't be released. Error code matches the last failed release. */ ErrCode ReleaseAllLockedResources (const char* dirpath, unsigned* failed); #ifdef __cplusplus }; #endif /* __cplusplus */ #endif /* locks.h */
14  * данных"
15  *
16  * Encoding: ISO-8859-5 (GOST)
17  *
18  *********************************************************************/
19 
20 #ifndef __locks_h
21 #define __locks_h
22 
23 #include <mix/Types.h>
24 #include <mix/wenv.h>
25 #include <mix/misc.h>
26 
27 
28 /***********************************************************************
29  *
30  * Simple exclusive lock API.
31  *
32  ***********************************************************************/
33 
34 
37 #define EXCL_LOCK_TRIES 5
38 
40 #define EXCL_LOCK_DELAY 1
41 
43 #define EXCL_LOCK_DELAY_US 50000
44 
45 
47 typedef Int4 LockId;
48 
49 
52 #define PROCESS_LOCK_IPC_ID 168
53 
56 #define PROCESS_LOCK_SEM_KEY 1
57 
58 
61 typedef enum {
62  plrHardKeyAccess = 0,
63  plrSessionManagement,
64  plrKeysourcerCell,
66  __plrNumber
68 } ProcessLockReason;
69 
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif /* __cplusplus */
74 
76 Logic LockCheck (LockId lid);
77 
81 ErrCode LockResourceExclusive (LockId* plid, const char* path);
82 
84 ErrCode LockProcess (LockId* plid, ProcessLockReason reason);
85 
87 ErrCode LockAtExit (LockId* plid, weAtExitHandlerProc proc);
88 
90 ErrCode UnlockResourceById (LockId lid);
91 
92 
95 void UnlockAllResources ();
96 
97 
98 /*
99  * Special lock supervisor operations. They operate over other
100  * application's locks and may cause unreliable simultaneous access
101  * to the same file/db objects.
102  */
103 
107 Logic CheckLockedResource (const char* path);
108 
110 ErrCode ListLockedResources (const char* dirpath, unsigned* n,
111  STRLIST* list);
112 
116 ErrCode ReleaseLockedResource (const char* path);
117 
123 ErrCode ReleaseAllLockedResources (const char* dirpath, unsigned* failed);
124 
125 
126 
127 #ifdef __cplusplus
128 };
129 #endif /* __cplusplus */
130 
131 #endif /* locks.h */