-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunnable.cpp
More file actions
73 lines (56 loc) · 1.67 KB
/
Runnable.cpp
File metadata and controls
73 lines (56 loc) · 1.67 KB
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
63
64
65
66
67
68
69
70
71
72
73
//
// Created by theo on 5/22/2021.
//
#include "Runnable.h"
#include <functional>
#include <utility>
mtl::Runnable::Runnable(std::function<void(void *)> fun, void *funArg, bool destroy) {
timeout = -1;
this->fun = std::move(fun);
this->funArg = funArg;
this->destroy = destroy;
}
mtl::Runnable::Runnable(std::function<void(void *)> fun, void *funArg, void *desFunArg,
std::function<void(void *)> desFun, bool destroy) {
timeout = -1;
this->fun = std::move(fun);
this->destructorFun = std::move(desFun);
this->funArg = funArg;
destructorFunArg = desFunArg;
this->destroy = destroy;
}
mtl::Runnable::Runnable(std::function<void(void *)> fun, void *funArg, long timeout, bool destroy) {
this->fun = std::move(fun);
this->timeout = timeout;
this->funArg = funArg;
this->destroy = destroy;
}
mtl::Runnable::Runnable(std::function<void(void *)> fun, void *funArg, std::function<void(void *)> desFun, void *desFunArg,
long timeout, bool destroy) {
this->timeout = timeout;
this->fun = std::move(fun);
this->destructorFun = std::move(desFun);
this->funArg = funArg;
destructorFunArg = desFunArg;
this->destroy = destroy;
}
mtl::Runnable::~Runnable() {
if (destructorFun != nullptr){
destructorFun(destructorFunArg);
}
}
long mtl::Runnable::getTimeout() const {
return timeout;
}
bool mtl::Runnable::hasTimeout() const {
return timeout != -1;
}
void *mtl::Runnable::getArgument() const {
return funArg;
}
std::function<void(void*)> mtl::Runnable::getFunction() const{
return fun;
}
bool mtl::Runnable::destroyMe() const {
return destroy;
}