MCPcopy Create free account
hub / github.com/alibaba/async_simple / thread

Class thread

demo_example/asio/asio/thread.hpp:48–86  ·  view source on GitHub ↗

A simple abstraction for starting threads. * The asio::thread class implements the smallest possible subset of the * functionality of boost::thread. It is intended to be used only for starting * a thread and waiting for it to exit. If more extensive threading * capabilities are required, you are strongly advised to use something else. * * @par Thread Safety * @e Distinct @e objects: Safe.@n

Source from the content-addressed store, hash-verified

46 * t.join(); @endcode
47 */
48class thread
49 : private noncopyable
50{
51public:
52 /// Start a new thread that executes the supplied function.
53 /**
54 * This constructor creates a new thread that will execute the given function
55 * or function object.
56 *
57 * @param f The function or function object to be run in the thread. The
58 * function signature must be: @code void f(); @endcode
59 */
60 template <typename Function>
61 explicit thread(Function f)
62 : impl_(f)
63 {
64 }
65
66 /// Destructor.
67 ~thread()
68 {
69 }
70
71 /// Wait for the thread to exit.
72 /**
73 * This function will block until the thread has exited.
74 *
75 * If this function is not called before the thread object is destroyed, the
76 * thread itself will continue to run until completion. You will, however,
77 * no longer have the ability to wait for it to exit.
78 */
79 void join()
80 {
81 impl_.join();
82 }
83
84private:
85 detail::thread impl_;
86};
87
88} // namespace asio
89

Callers 15

mainFunction · 0.85
scheduleMethod · 0.85
initMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
applyValueMethod · 0.85
await_suspendMethod · 0.85
await_suspendMethod · 0.85
scheduleMethod · 0.85
CallBackSystemMethod · 0.85
sumMethod · 0.85
delayedTaskMethod · 0.85

Calls

no outgoing calls

Tested by 11

TEST_FFunction · 0.68
TEST_FFunction · 0.68
applyValueMethod · 0.68
await_suspendMethod · 0.68
await_suspendMethod · 0.68
scheduleMethod · 0.68
CallBackSystemMethod · 0.68
sumMethod · 0.68
delayedTaskMethod · 0.68
await_suspendMethod · 0.68
await_suspendMethod · 0.68