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
68
69
70
71
72
73
74
75
76
77
78
79
/*
============================================================================
Name : hev-task-mutex.h
Author : Heiher <r@hev.cc>
Copyright : Copyright (c) 2019 everyone.
Description : Mutex
============================================================================
*/
#ifndef __HEV_TASK_MUTEX_H__
#define __HEV_TASK_MUTEX_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _HevTaskMutex HevTaskMutex;
typedef struct _HevTaskMutexNode HevTaskMutexNode;
struct _HevTaskMutex
{
unsigned int locker;
HevTaskMutexNode *waiters;
};
/**
* hev_task_mutex_init:
* @self: a #HevTaskMutex
*
* Initialize the task mutex.
*
* Returns: When successful, returns zero. When an error occurs, returns -1.
*
* Since: 4.3
*/
int hev_task_mutex_init (HevTaskMutex *self);
/**
* hev_task_mutex_lock:
* @self: a #HevTaskMutex
*
* Lock the task mutex.
*
* Returns: When successful, returns zero. When an error occurs, returns -1.
*
* Since: 4.3
*/
int hev_task_mutex_lock (HevTaskMutex *self);
/**
* hev_task_mutex_trylock:
* @self: a #HevTaskMutex
*
* Try lock the task mutex.
*
* Returns: When successful, returns zero. When an error occurs, returns -1.
*
* Since: 4.3
*/
int hev_task_mutex_trylock (HevTaskMutex *self);
/**
* hev_task_mutex_unlock:
* @self: a #HevTaskMutex
*
* Unlock the task mutex.
*
* Returns: When successful, returns zero. When an error occurs, returns -1.
*
* Since: 4.3
*/
int hev_task_mutex_unlock (HevTaskMutex *self);
#ifdef __cplusplus
}
#endif
#endif /* __HEV_TASK_MUTEX_H__ */