RetroArch
rthreads.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (rthreads.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __LIBRETRO_SDK_RTHREADS_H__
24 #define __LIBRETRO_SDK_RTHREADS_H__
25 
26 #include <retro_common_api.h>
27 
28 #include <boolean.h>
29 #include <stdint.h>
30 #include <retro_inline.h>
31 #include <retro_miscellaneous.h>
32 
34 
35 typedef struct sthread sthread_t;
36 typedef struct slock slock_t;
37 typedef struct scond scond_t;
38 
39 #ifdef HAVE_THREAD_STORAGE
40 typedef unsigned sthread_tls_t;
41 #endif
42 
53 sthread_t *sthread_create(void (*thread_func)(void*), void *userdata);
54 
70 sthread_t *sthread_create_with_priority(void (*thread_func)(void*), void *userdata, int thread_priority);
71 
83 int sthread_detach(sthread_t *thread);
84 
96 void sthread_join(sthread_t *thread);
97 
104 bool sthread_isself(sthread_t *thread);
105 
114 slock_t *slock_new(void);
115 
122 void slock_free(slock_t *lock);
123 
132 void slock_lock(slock_t *lock);
133 
140 void slock_unlock(slock_t *lock);
141 
151 scond_t *scond_new(void);
152 
159 void scond_free(scond_t *cond);
160 
168 void scond_wait(scond_t *cond, slock_t *lock);
169 
182 bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us);
183 
191 int scond_broadcast(scond_t *cond);
192 
200 void scond_signal(scond_t *cond);
201 
202 #ifdef HAVE_THREAD_STORAGE
203 
217 bool sthread_tls_create(sthread_tls_t *tls);
218 
224 bool sthread_tls_delete(sthread_tls_t *tls);
225 
234 void *sthread_tls_get(sthread_tls_t *tls);
235 
241 bool sthread_tls_set(sthread_tls_t *tls, const void *data);
242 #endif
243 
245 
246 #endif
sthread_t * sthread_create(void(*thread_func)(void *), void *userdata)
Definition: rthreads.c:163
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
scond_t * scond_new(void)
Definition: rthreads.c:416
Definition: rthreads.c:88
static int cond(LexState *ls)
Definition: lparser.c:1177
Definition: ibxm.h:9
typedefRETRO_BEGIN_DECLS struct sthread sthread_t
Definition: rthreads.h:35
Definition: rthreads.c:78
void sthread_join(sthread_t *thread)
Definition: rthreads.c:288
Definition: rthreads.c:106
void slock_free(slock_t *lock)
Definition: rthreads.c:358
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
signed __int64 int64_t
Definition: stdint.h:135
slock_t * slock_new(void)
Definition: rthreads.c:328
int sthread_detach(sthread_t *thread)
Definition: rthreads.c:266
void slock_unlock(slock_t *lock)
Definition: rthreads.c:396
bool sthread_isself(sthread_t *thread)
Definition: rthreads.c:307
void slock_lock(slock_t *lock)
Definition: rthreads.c:379
sthread_t * sthread_create_with_priority(void(*thread_func)(void *), void *userdata, int thread_priority)
Definition: rthreads.c:188