Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
tbb
test
test_thread.cxx
Go to the documentation of this file.
1
#include <iostream>
2
#include <sstream>
3
#include <chrono>
4
#include <thread>
5
void
msleep
(
int
msec)
6
{
7
std::this_thread::sleep_for(
std::chrono::milliseconds
(msec));
8
}
9
10
using namespace
std
;
11
12
struct
Fun
{
13
int
n
;
14
Fun
(
int
n):n(n) {}
15
int
operator()
(
int
x
,
bool
dec
) {
16
while
(x>0) {
17
int
old_n =
n
;
18
if
(dec) {
19
n =
x
;
20
}
21
stringstream
msg
;
22
msg <<
this
<<
" n="
<< n <<
" (was:"
<< old_n <<
") x="
<< x <<
"\n"
;
23
cerr << msg.str();
24
--
x
;
25
msleep
(x);
26
}
27
return
0;
28
}
29
};
30
31
int
main
() {
32
33
Fun
f1
(1);
34
35
std::thread
t1
(f1,42,
true
);
36
std::thread t2(f1,69,
false
);
37
t1.join();
38
t2.join();
39
40
return
0;
41
}
main
int main()
Definition:
test_thread.cxx:31
Fun
Definition:
test_thread.cxx:12
msg
void msg(const char *fmt,...)
Definition:
message.cpp:107
Fun::operator()
int operator()(int x, bool dec)
Definition:
test_thread.cxx:15
std
STL namespace.
larg4::f1
EmPhysicsFactory f1
Definition:
CustomPhysicsBuiltIns.cxx:10
test_gpu_visible.t1
t1
Definition:
test_gpu_visible.py:16
dec
QTextStream & dec(QTextStream &s)
Definition:
qtextstream.cpp:2018
msleep
void msleep(int msec)
Definition:
test_thread.cxx:5
util::quantities::milliseconds
millisecond milliseconds
Alias for common language habits.
Definition:
spacetime.h:100
Fun::n
int n
Definition:
test_thread.cxx:13
train.x
list x
Definition:
train.py:276
n
std::size_t n
Definition:
format.h:3399
Fun::Fun
Fun(int n)
Definition:
test_thread.cxx:14
Generated by
1.8.11