libiec61850  1.2.0
hal_thread.h
Go to the documentation of this file.
1 /*
2  * thread_hal.h
3  *
4  * Multi-threading abstraction layer
5  *
6  * Copyright 2013, 2014 Michael Zillgith
7  *
8  * This file is part of libIEC61850.
9  *
10  * libIEC61850 is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * libIEC61850 is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * See COPYING file for the complete license text.
24  */
25 
26 #ifndef THREAD_HAL_H_
27 #define THREAD_HAL_H_
28 
29 #include <stdbool.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 
48 typedef struct sThread* Thread;
49 
51 typedef void* Semaphore;
52 
54 typedef void* (*ThreadExecutionFunction) (void*);
55 
65 Thread
66 Thread_create(ThreadExecutionFunction function, void* parameter, bool autodestroy);
67 
76 void
77 Thread_start(Thread thread);
78 
84 void
85 Thread_destroy(Thread thread);
86 
90 void
91 Thread_sleep(int millies);
92 
93 Semaphore
94 Semaphore_create(int initialValue);
95 
96 /* Wait until semaphore value is greater than zero. Then decrease the semaphore value. */
97 void
98 Semaphore_wait(Semaphore self);
99 
100 void
101 Semaphore_post(Semaphore self);
102 
103 void
104 Semaphore_destroy(Semaphore self);
105 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 
115 #endif /* THREAD_HAL_H_ */
Semaphore Semaphore_create(int initialValue)
void Semaphore_post(Semaphore self)
void Semaphore_wait(Semaphore self)
Thread Thread_create(ThreadExecutionFunction function, void *parameter, bool autodestroy)
Create a new Thread instance.
void * Semaphore
Definition: hal_thread.h:51
void Thread_destroy(Thread thread)
Destroy a Thread and free all related resources.
void *(* ThreadExecutionFunction)(void *)
Definition: hal_thread.h:54
void Thread_start(Thread thread)
Start a Thread.
void Semaphore_destroy(Semaphore self)
struct sThread * Thread
Definition: hal_thread.h:48
void Thread_sleep(int millies)
Suspend execution of the Thread for the specified number of milliseconds.