forked from kevinlin311tw/Caffe-DeepBinaryCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinternal_thread.cpp
More file actions
39 lines (33 loc) · 730 Bytes
/
internal_thread.cpp
File metadata and controls
39 lines (33 loc) · 730 Bytes
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
#include "caffe/internal_thread.hpp"
#include "caffe/util/thread.hpp"
namespace caffe {
InternalThread::~InternalThread() {
WaitForInternalThreadToExit();
if (thread_ != NULL) {
delete thread_;
}
}
bool InternalThread::StartInternalThread() {
if (!WaitForInternalThreadToExit()) {
return false;
}
try {
thread_ = new caffe::Thread
(&InternalThread::InternalThreadEntry, this);
} catch (...) {
return false;
}
return true;
}
/** Will not return until the internal thread has exited. */
bool InternalThread::WaitForInternalThreadToExit() {
if (is_started()) {
try {
thread_->join();
} catch (...) {
return false;
}
}
return true;
}
} // namespace caffe