-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreads.h
executable file
·62 lines (51 loc) · 1.17 KB
/
Threads.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* File: Threads.h
* Author: Anton
*
* Created on 24 ноября 2019 г., 16:34
*/
#ifndef NEUROTHREADS_H
#define NEUROTHREADS_H
#include "libexport.h"
#ifdef _WIN32
#include <windows.h> //Нужна для потоков в winapi
#else
#include <pthread.h>
#include <signal.h>
#endif
#define STATE_NOT_READY 0
#define STATE_READY 1
#define STATE_EXCITED 2
#define NANO 1000000000L
typedef struct _cross_platform_thread_struct_{
int status;
#ifdef _WIN32
HANDLE thread;
LPDWORD ThreadId;
#else
pthread_t thread;
#endif
int errcode; //errcode потока
long ThreadTime; //Аптайм потока c момента предшествующей остановки
}CPT;
typedef struct _thread_attr_core_ {
CPT *obj;
void(*entrypoint) (void *);
void *attrs;
}TAC;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#define _wCrossThreadExit(); ExitThread(0);
#else
#define _wCrossThreadExit(); pthread_exit(NULL);
#endif
DLL_EXPORT int _wCrossThreadCreate(CPT *tr,void (*entrypoint) (void *),void *attrs);
void _wCrossThreadClose(CPT *tr);
long _wCrossThreadPause(CPT *tr);
long _wCrossThreadResume(CPT *tr);
#ifdef __cplusplus
}
#endif
#endif