-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrwlock.h
67 lines (57 loc) · 1.67 KB
/
rwlock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Project: Read-Write Lock for C
* File: rwlock.h
* Author: Jason Papapanagiotakis
* Github: https://github.com/JasonPap/ReadWriteLock
*/
#ifndef RWLOCK_H
#define RWLOCK_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ReadWriteLock_s* ReadWriteLock;
/* This function allocates and initializes the read-write lock.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_init(ReadWriteLock*);
/* This function deletes the read-write lock object and release
* the resources allocated.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_destroy(ReadWriteLock*);
/* This function lock the read-write lock for write usage.
* Will return when the lock is obtained.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_writeLock(ReadWriteLock);
/* This function release the read-write lock from write usage.
* Will return when the lock is released.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_writeUnlock(ReadWriteLock);
/* This function lock the read-write lock for read usage.
* Will return when the lock is obtained.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_readLock(ReadWriteLock);
/* This function release the read-write lock from read usage.
* Will return when the lock is released.
* Return values:
* [*] On success, 0 is returned
* [*] On failure, -1 is returned
*/
int rwl_readUnlock(ReadWriteLock);
#ifdef __cplusplus
}
#endif
#endif /* RWLOCK_H */