ythread.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: ythread.h 26732 2017-03-09 17:12:22Z mvuilleu $
4  *
5  * OS-independent thread and synchronization library
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 #ifndef YTHREAD_H
41 #define YTHREAD_H
42 #include "ydef.h"
43 
44 /*********************************************************************
45  * EVENT FUNCTION
46  *********************************************************************/
47 
48 #ifdef WINDOWS_API
49 #if defined(__BORLANDC__)
50 #pragma warn -8019
51 #include <windows.h>
52 #pragma warn +8019
53 #else
54 #include <windows.h>
55 #endif
56 typedef HANDLE yEvent;
57 #else
58 #include <pthread.h>
59 
60 
61 typedef struct {
62  pthread_cond_t cond;
63  pthread_mutex_t mtx;
64  int verif;
65  int autoreset;
66 } yEvent;
67 
68 #endif
69 
70 void yCreateEvent(yEvent *ev);
71 void yCreateManualEvent(yEvent *event,int initialState);
72 void ySetEvent(yEvent* ev);
73 void yResetEvent(yEvent *ev);
74 int yWaitForEvent(yEvent *ev,int time);
75 void yCloseEvent(yEvent *ev);
76 
77 
78 /*********************************************************************
79  * THREAD FUNCTION
80  *********************************************************************/
81 #ifdef WIN32
82 typedef HANDLE osThread;
83 #else
84 typedef pthread_t osThread;
85 #endif
86 
87 typedef enum {
93 
94 
95 typedef struct {
96  void *ctx;
100 } yThread;
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 int yCreateDetachedThread(void* (*fun)(void *), void *arg);
107 
108 int yThreadCreate(yThread *yth,void* (*fun)(void *), void *arg);
109 int yThreadIsRunning(yThread *yth);
110 void yThreadSignalStart(yThread *yth);
111 void yThreadSignalEnd(yThread *yth);
112 void yThreadRequestEnd(yThread *yth);
113 int yThreadMustEnd(yThread *yth);
114 void yThreadKill(yThread *yth);
115 int yThreadIndex(void);
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif
122 
123 
YTHREAD_STATE st
Definition: ythread.h:98
pthread_mutex_t mtx
Definition: ythread.h:63
void yCreateManualEvent(yEvent *event, int initialState)
Definition: ythread.c:167
int autoreset
Definition: ythread.h:65
void yThreadKill(yThread *yth)
Definition: ythread.c:343
int yThreadMustEnd(yThread *yth)
Definition: ythread.c:338
int yThreadCreate(yThread *yth, void *(*fun)(void *), void *arg)
Definition: ythread.c:293
osThread th
Definition: ythread.h:99
void yCloseEvent(yEvent *ev)
Definition: ythread.c:223
void * ctx
Definition: ythread.h:96
int yThreadIsRunning(yThread *yth)
Definition: ythread.c:311
void yCreateEvent(yEvent *ev)
Definition: ythread.c:159
int yCreateDetachedThread(void *(*fun)(void *), void *arg)
Definition: ythread.c:282
int yThreadIndex(void)
Definition: ythread.c:264
void yThreadRequestEnd(yThread *yth)
Definition: ythread.c:331
void ySetEvent(yEvent *ev)
Definition: ythread.c:175
int yWaitForEvent(yEvent *ev, int time)
Definition: ythread.c:196
pthread_t osThread
Definition: ythread.h:84
Definition: ythread.h:61
YTHREAD_STATE
Definition: ythread.h:87
void yResetEvent(yEvent *ev)
Definition: ythread.c:187
yEvent ev
Definition: ythread.h:97
int verif
Definition: ythread.h:64
void yThreadSignalEnd(yThread *yth)
Definition: ythread.c:326
pthread_cond_t cond
Definition: ythread.h:62
void yThreadSignalStart(yThread *yth)
Definition: ythread.c:318


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13