| 82 | bool StartThread(CThread& th, ThreadFunc&& f, void* args, const string& name) |
| 83 | #else |
| 84 | bool StartThread(CThread& th, void* (*f) (void*), void* args, const string& name) |
| 85 | #endif |
| 86 | { |
| 87 | ThreadName tn(name); |
| 88 | try |
| 89 | { |
| 90 | #if HAVE_FULL_CXX11 || defined(ENABLE_STDCXX_SYNC) |
| 91 | th = CThread(f, args); |
| 92 | #else |
| 93 | // No move semantics in C++03, therefore using a dedicated function |
| 94 | th.create_thread(f, args); |
| 95 | #endif |
| 96 | } |
| 97 | #if ENABLE_HEAVY_LOGGING |
| 98 | catch (const CThreadException& e) |
| 99 | #else |
| 100 | catch (const CThreadException&) |
| 101 | #endif |
| 102 | { |
| 103 | HLOGC(inlog.Debug, log << name << ": failed to start thread. " << e.what()); |
| 104 | return false; |
| 105 | } |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | } // namespace sync |
| 110 | } // namespace srt |