Robot Raconteur Core C++ Library
Toggle main menu visibility
Loading...
Searching...
No Matches
RobotRaconteurCore
include
RobotRaconteur
RobotRaconteurEmscripten.h
1
#pragma once
2
3
#include <boost/date_time/posix_time/ptime.hpp>
4
#include <boost/function.hpp>
5
#include <boost/system/error_code.hpp>
6
#include <boost/shared_ptr.hpp>
7
8
namespace
RobotRaconteur
9
{
10
class
WallTimer;
11
}
12
13
namespace
boost
14
{
15
template
<
typename
T>
16
class
null_lock
17
{
18
public
:
19
null_lock() {}
20
template
<
typename
U>
21
null_lock(U& u)
22
{}
23
void
lock() {}
24
void
unlock() {}
25
26
template
<
typename
U>
27
void
swap(U& l)
28
{}
29
};
30
31
template
<
typename
T>
32
using
unique_lock = null_lock<T>;
33
template
<
typename
T>
34
using
shared_lock = null_lock<T>;
35
template
<
typename
T>
36
using
upgrade_lock = null_lock<T>;
37
template
<
typename
T>
38
using
upgrade_to_unique_lock = null_lock<T>;
39
40
class
null_mutex
41
{
42
public
:
43
null_mutex() {}
44
45
void
lock() {}
46
void
notify_all() {}
47
void
unlock() {}
48
void
notify_one() {}
49
50
template
<
typename
U>
51
void
wait(U& u)
52
{
53
throw
std::runtime_error(
"Operation requires threading"
);
54
}
55
56
template
<
typename
U,
typename
V>
57
void
timed_wait(U& u, V v)
58
{
59
throw
std::runtime_error(
"Operation requires threading"
);
60
}
61
62
template
<
typename
U,
typename
V>
63
void
wait_for(U& u, V v)
64
{
65
throw
std::runtime_error(
"Operation requires threading"
);
66
}
67
68
typedef
unique_lock<null_mutex> scoped_lock;
69
};
70
71
typedef
boost::null_mutex mutex;
72
typedef
boost::null_mutex recursive_mutex;
73
typedef
boost::null_mutex shared_mutex;
74
typedef
boost::null_mutex condition_variable;
75
76
namespace
asio
77
{
78
class
strand
79
{
80
public
:
81
template
<
typename
T>
82
strand(T& t)
83
{}
84
};
85
class
io_service_work
86
{
87
public
:
88
template
<
typename
U>
89
io_service_work(U& u)
90
{}
91
};
92
class
io_service
93
{
94
public
:
95
typedef
io_service_work work;
96
typedef
strand strand;
97
void
run_one() {}
98
bool
stopped() {
return
false
; }
99
void
stop() {}
100
void
post(boost::function<
void
()> f);
101
};
102
class
deadline_timer
103
{
104
public
:
105
deadline_timer(io_service& service);
106
deadline_timer(io_service& service, boost::posix_time::time_duration duration);
107
~deadline_timer();
108
void
expires_from_now(boost::posix_time::time_duration duration);
109
boost::posix_time::time_duration expires_from_now();
110
void
expires_at(boost::posix_time::ptime duration);
111
void
async_wait(boost::function<
void
(boost::system::error_code)> f);
112
void
cancel();
113
void
cancel(boost::system::error_code ec);
114
void
wait();
115
116
protected
:
117
boost::shared_ptr<RobotRaconteur::WallTimer> timer;
118
double
next_timeout;
119
};
120
}
// namespace asio
121
122
template
<
typename
T>
123
class
thread_specific_ptr
124
{
125
T* val_;
126
127
public
:
128
thread_specific_ptr() : val_(0) {}
129
thread_specific_ptr(T* val) : val_(val) {}
130
131
void
reset(T* val)
132
{
133
if
(val_)
134
{
135
delete
val_;
136
}
137
val_ = val;
138
}
139
140
void
reset() { reset(0); }
141
142
T* get() {
return
val_; }
143
144
T& operator*() {
return
*val_; }
145
};
146
147
class
thread
148
{
149
public
:
150
thread() {}
151
template
<
typename
U>
152
thread(U u)
153
{}
154
155
void
join() {}
156
};
157
158
typedef
boost::posix_time::ptime system_time;
159
160
namespace
this_thread
161
{
162
template
<
typename
T>
163
static
void
sleep(T& t)
164
{
165
throw
std::runtime_error(
"Operation requires threading"
);
166
}
167
168
int
get_id();
169
}
// namespace this_thread
170
}
// namespace boost
171
172
#undef RR_BOOST_ASIO_STRAND_WRAP
173
#define RR_BOOST_ASIO_STRAND_WRAP(strand, f) (f)
Generated by
1.17.0