Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/devdoc/lock_requirements.md

raw
1 # lock
2
3
4 ## Overview
5
6 The **lock** adapter implements synchronization needed with the **threadapi** adapter.
7
8 A functional Lock adapter implementation is only required if the optional threadapi adapter is being used.
9
10 ## Exposed API
11 **SRS_LOCK_10_001: [** `Lock` interface exposes the following APIs **]**
12 ```c
13 typedef enum LOCK_RESULT_TAG
14 {
15 LOCK_OK,
16 LOCK_ERROR
17 } LOCK_RESULT;
18 ```
19
20 ```c
21 typedef void* HANDLE_LOCK;
22 ```
23 **SRS_LOCK_10_015: [** This is the handle to the different lock instances **]**
24
25 ```c
26 HANDLE_LOCK Lock_Init (void);
27 ```
28 **SRS_LOCK_30_001: [** If the **lock** adapter is not implemented, `Lock_Init` shall return NULL. **]**
29
30 **SRS_LOCK_10_002: [** `Lock_Init` on success shall return a valid lock handle which should be a non-`NULL` value **]**
31
32 **SRS_LOCK_10_003: [** `Lock_Init` on error shall return `NULL` **]**
33
34 ```c
35 LOCK_RESULT Lock(HANDLE_LOCK handle);
36 ```
37 **SRS_LOCK_30_001: [** If the **lock** adapter is not implemented, `Lock` shall return `LOCK_ERROR`. **]**
38
39 **SRS_LOCK_10_004: [** `Lock` shall be implemented as a non-recursive lock **]**
40
41 **SRS_LOCK_10_005: [** `Lock` on success shall return `LOCK_OK` **]**
42
43 **SRS_LOCK_10_006: [** `Lock` on error shall return `LOCK_ERROR` **]**
44
45 **SRS_LOCK_10_007: [** `Lock` on `NULL` handle passed returns `LOCK_ERROR` **]**
46
47 ```c
48 LOCK_RESULT Unlock(HANDLE_LOCK handle);
49 ```
50 **SRS_LOCK_30_001: [** If the **lock** adapter is not implemented, `Unlock` shall return `LOCK_ERROR`. **]**
51
52 **SRS_LOCK_10_008: [** `Unlock` shall be implemented as a mutex unlock **]**
53
54 **SRS_LOCK_10_009: [** `Unlock` on success shall return `LOCK_OK` **]**
55
56 **SRS_LOCK_10_010: [** `Unlock` on error shall return `LOCK_ERROR` **]**
57
58 **SRS_LOCK_10_011: [** `Unlock` on `NULL` handle passed returns `LOCK_ERROR` **]**
59
60 ```c
61 LOCK_RESULT Lock_Deinit(HANDLE_LOCK handle);
62 ```
63 **SRS_LOCK_30_001: [** If the **lock** adapter is not implemented, `Lock_Deinit` shall do nothing. **]**
64
65 **SRS_LOCK_10_012: [** `Lock_Deinit` frees all resources associated with `handle` **]**
66
67 **SRS_LOCK_10_013: [** `Lock_Deinit` on NULL `handle` passed returns `LOCK_ERROR` **]**