plibsys  0.0.4
psemaphore.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2010-2017 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
94 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
95 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
96 #endif
97 
98 #ifndef PLIBSYS_HEADER_PSEMAPHORE_H
99 #define PLIBSYS_HEADER_PSEMAPHORE_H
100 
101 #include <pmacros.h>
102 #include <ptypes.h>
103 #include <perror.h>
104 
106 
108 typedef enum PSemaphoreAccessMode_ {
112 
114 typedef struct PSemaphore_ PSemaphore;
115 
133  pint init_val,
135  PError **error);
136 
158 
167  PError **error);
168 
177  PError **error);
178 
188 
190 
191 #endif /* PLIBSYS_HEADER_PSEMAPHORE_H */
P_LIB_API pboolean p_semaphore_acquire(PSemaphore *sem, PError **error)
Acquires (P operation) a semaphore.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
Creates semaphore, resets to a given value if exists.
Definition: psemaphore.h:110
Opens an existing semaphore or creates one with a given value.
Definition: psemaphore.h:109
int pint
Type for an int.
Definition: ptypes.h:120
char pchar
Type for a char.
Definition: ptypes.h:116
struct PError_ PError
Opaque data structure for an error object.
Definition: perror.h:68
Miscellaneous macros.
P_LIB_API pboolean p_semaphore_release(PSemaphore *sem, PError **error)
Releases (V operation) a semaphore.
signed int pboolean
Type for a bool.
Definition: ptypes.h:114
P_LIB_API void p_semaphore_free(PSemaphore *sem)
Frees PSemaphore object.
P_LIB_API PSemaphore * p_semaphore_new(const pchar *name, pint init_val, PSemaphoreAccessMode mode, PError **error)
Creates a new PSemaphore object.
Error report system.
struct PSemaphore_ PSemaphore
Semaphore opaque data structure.
Definition: psemaphore.h:114
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
PSemaphoreAccessMode_
Enum with semaphore creation modes.
Definition: psemaphore.h:108
Types definitions.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298
enum PSemaphoreAccessMode_ PSemaphoreAccessMode
Enum with semaphore creation modes.
P_LIB_API void p_semaphore_take_ownership(PSemaphore *sem)
Takes ownership of a semaphore.