Zen API
 All Classes Files Functions Variables Typedefs Macros Groups Pages
kSemaphore.h
Go to the documentation of this file.
1 /**
2  * @file kSemaphore.h
3  * @brief Declares the kSemaphore class.
4  *
5  * @internal
6  * Copyright (C) 2010-2014 by LMI Technologies Inc.
7  * Licensed under the MIT License.
8  * Redistributed files must retain the above copyright notice.
9  */
10 #ifndef K_API_SEMAPHORE_H
11 #define K_API_SEMAPHORE_H
12 
13 #include <kApi/kApiDef.h>
14 
15 kBeginHeader()
16 
17 /**
18  * @class kSemaphore
19  * @extends kObject
20  * @ingroup kApi-Threads
21  * @brief Represents a semaphore.
22  */
23 //typedef kObject kSemaphore; --forward-declared in kApiDef.x.h
24 
25 /**
26  * Constructs a semaphore object.
27  *
28  * @public @memberof kSemaphore
29  * @param semaphore Destination for the constructed object handle.
30  * @param initialCount Initial value of the semaphore.
31  * @param allocator Memory allocator (or kNULL for default).
32  * @return Operation status.
33  */
34 kFx(kStatus) kSemaphore_Construct(kSemaphore* semaphore, kSize initialCount, kAlloc allocator);
35 
36 /**
37  * Increments the semaphore.
38  *
39  * @public @memberof kSemaphore
40  * @param semaphore Semaphore object.
41  * @return Operation status.
42  */
43 kFx(kStatus) kSemaphore_Post(kSemaphore semaphore);
44 
45 /**
46  * Waits until the semaphore can be decremented or the timeout interval has elapsed.
47  *
48  * kERROR_TIMEOUT is returned if the timeout elapses before the semaphore can be decremented.
49  *
50  * @public @memberof kSemaphore
51  * @param semaphore Semaphore object.
52  * @param timeout Timeout in microseconds, or kINFINITE to wait indefinitely.
53  * @return Operation status.
54  */
55 kFx(kStatus) kSemaphore_Wait(kSemaphore semaphore, k64u timeout);
56 
57 kEndHeader()
58 
59 #include <kApi/Threads/kSemaphore.x.h>
60 
61 #endif
kStatus kSemaphore_Wait(kSemaphore semaphore, k64u timeout)
Waits until the semaphore can be decremented or the timeout interval has elapsed. ...
Represents a 64-bit unsigned integer.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
Represents a semaphore.
Essential API declarations.
Represents an enumeration of error codes.
kStatus kSemaphore_Post(kSemaphore semaphore)
Increments the semaphore.
kStatus kSemaphore_Construct(kSemaphore *semaphore, kSize initialCount, kAlloc allocator)
Constructs a semaphore object.