-
Notifications
You must be signed in to change notification settings - Fork 3
/
Thread.hh
50 lines (37 loc) · 861 Bytes
/
Thread.hh
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
/**
* Copyright 2017 M. Shulhan (ms@kilabit.info). All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef _LIBVOS_THREAD_HH
#define _LIBVOS_THREAD_HH 1
#include "Locker.hh"
namespace vos {
class Thread : public Locker {
public:
explicit Thread(void* (*fn)(void* arg) = NULL);
~Thread();
void* _arg;
virtual void* run(void* arg = NULL);
int is_running();
pthread_t get_id();
virtual int start(void* arg = NULL);
void stop();
int wait();
int wakeup();
int join(void** res = NULL);
static const char* __cname;
static void* RUN(void *arg);
private:
Thread(const Thread&);
void operator=(const Thread&);
int _init;
uint8_t _running;
uint16_t _waiting;
pthread_t _id;
pthread_attr_t _attr;
pthread_cond_t _cond;
void *(*_fn)(void* arg);
};
}
#endif