-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathlock.h
More file actions
77 lines (64 loc) · 2.23 KB
/
lock.h
File metadata and controls
77 lines (64 loc) · 2.23 KB
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
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/** @file lock.h
* @brief A minimalistic platform agnostic lock abstraction for thread
* synchronization.
* @details The Lock component is implemented in order to achieve thread
* synchronization, as we may have a requirement to consume locks
* across different platforms. This component exposes some generic
* APIs so that it can be extended for platform specific
* implementations.
*/
#ifndef LOCK_H
#define LOCK_H
#include "azure_macro_utils/macro_utils.h"
#include "umock_c/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void* LOCK_HANDLE;
#define LOCK_RESULT_VALUES \
LOCK_OK, \
LOCK_ERROR \
/** @brief Enumeration specifying the lock status.
*/
MU_DEFINE_ENUM(LOCK_RESULT, LOCK_RESULT_VALUES);
/**
* @brief This API creates and returns a valid lock handle.
*
* @return A valid @c LOCK_HANDLE when successful or @c NULL otherwise.
*/
MOCKABLE_FUNCTION(, LOCK_HANDLE, Lock_Init);
/**
* @brief Acquires a lock on the given lock handle. Uses platform
* specific mutex primitives in its implementation.
*
* @param handle A valid handle to the lock.
*
* @return Returns @c LOCK_OK when a lock has been acquired and
* @c LOCK_ERROR when an error occurs.
*/
MOCKABLE_FUNCTION(, LOCK_RESULT, Lock, LOCK_HANDLE, handle);
/**
* @brief Releases the lock on the given lock handle. Uses platform
* specific mutex primitives in its implementation.
*
* @param handle A valid handle to the lock.
*
* @return Returns @c LOCK_OK when the lock has been released and
* @c LOCK_ERROR when an error occurs.
*/
MOCKABLE_FUNCTION(, LOCK_RESULT, Unlock, LOCK_HANDLE, handle);
/**
* @brief The lock instance is destroyed.
*
* @param handle A valid handle to the lock.
*
* @return Returns @c LOCK_OK when the lock object has been
* destroyed and @c LOCK_ERROR when an error occurs.
*/
MOCKABLE_FUNCTION(, LOCK_RESULT, Lock_Deinit, LOCK_HANDLE, handle);
#ifdef __cplusplus
}
#endif
#endif /* LOCK_H */