MCPcopy Create free account
hub / github.com/comaps/comaps / SimpleThread

Class SimpleThread

libs/base/thread.hpp:79–112  ·  view source on GitHub ↗

A wrapper around a std thread which executes callable object in thread which is attached to JVM Class has the same interface as std::thread

Source from the content-addressed store, hash-verified

77/// A wrapper around a std thread which executes callable object in thread which is attached to JVM
78/// Class has the same interface as std::thread
79class SimpleThread
80{
81public:
82 using id = std::thread::id;
83 using native_handle_type = std::thread::native_handle_type;
84
85 SimpleThread() noexcept {}
86 SimpleThread(SimpleThread && x) noexcept : m_thread(std::move(x.m_thread)) {}
87
88 template <class Fn, class... Args>
89 explicit SimpleThread(Fn && fn, Args &&... args)
90 : m_thread(&SimpleThread::ThreadFunc, std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...))
91 {}
92
93 SimpleThread & operator=(SimpleThread && x) noexcept
94 {
95 m_thread = std::move(x.m_thread);
96 return *this;
97 }
98
99 void detach() { m_thread.detach(); }
100 id get_id() const noexcept { return m_thread.get_id(); }
101 void join() { m_thread.join(); }
102 bool joinable() const noexcept { return m_thread.joinable(); }
103 native_handle_type native_handle() { return m_thread.native_handle(); }
104 void swap(SimpleThread & x) noexcept { m_thread.swap(x.m_thread); }
105
106private:
107 static void ThreadFunc(std::function<void()> && fn);
108
109 DISALLOW_COPY(SimpleThread);
110
111 std::thread m_thread;
112};
113} // namespace threads

Callers 5

DeferredTaskMethod · 0.85
DelayedThreadPoolMethod · 0.85
ScheduleTaskMethod · 0.85
LoadMapsAsyncMethod · 0.85
AsyncRouterMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected