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

Method do_execute

demo_example/asio/asio/impl/thread_pool.hpp:102–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100template <typename Allocator, unsigned int Bits>
101template <typename Function>
102void thread_pool::basic_executor_type<Allocator,
103 Bits>::do_execute(ASIO_MOVE_ARG(Function) f, false_type) const
104{
105 typedef typename decay<Function>::type function_type;
106
107 // Invoke immediately if the blocking.possibly property is enabled and we are
108 // already inside the thread pool.
109 if ((bits_ & blocking_never) == 0 && pool_->scheduler_.can_dispatch())
110 {
111 // Make a local, non-const copy of the function.
112 function_type tmp(ASIO_MOVE_CAST(Function)(f));
113
114#if defined(ASIO_HAS_STD_EXCEPTION_PTR) \
115 && !defined(ASIO_NO_EXCEPTIONS)
116 try
117 {
118#endif // defined(ASIO_HAS_STD_EXCEPTION_PTR)
119 // && !defined(ASIO_NO_EXCEPTIONS)
120 detail::fenced_block b(detail::fenced_block::full);
121 asio_handler_invoke_helpers::invoke(tmp, tmp);
122 return;
123#if defined(ASIO_HAS_STD_EXCEPTION_PTR) \
124 && !defined(ASIO_NO_EXCEPTIONS)
125 }
126 catch (...)
127 {
128 pool_->scheduler_.capture_current_exception();
129 return;
130 }
131#endif // defined(ASIO_HAS_STD_EXCEPTION_PTR)
132 // && !defined(ASIO_NO_EXCEPTIONS)
133 }
134
135 // Allocate and construct an operation to wrap the function.
136 typedef detail::executor_op<function_type, Allocator> op;
137 typename op::ptr p = { detail::addressof(allocator_),
138 op::ptr::allocate(allocator_), 0 };
139 p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), allocator_);
140
141 if ((bits_ & relationship_continuation) != 0)
142 {
143 ASIO_HANDLER_CREATION((*pool_, *p.p,
144 "thread_pool", pool_, 0, "execute(blk=never,rel=cont)"));
145 }
146 else
147 {
148 ASIO_HANDLER_CREATION((*pool_, *p.p,
149 "thread_pool", pool_, 0, "execute(blk=never,rel=fork)"));
150 }
151
152 pool_->scheduler_.post_immediate_completion(p.p,
153 (bits_ & relationship_continuation) != 0);
154 p.v = p.p = 0;
155}
156
157template <typename Allocator, unsigned int Bits>
158template <typename Function>

Callers 3

do_bulk_executeMethod · 0.95
executeFunction · 0.45
executeFunction · 0.45

Calls 4

invokeFunction · 0.85
allocateFunction · 0.50
waitMethod · 0.45

Tested by

no test coverage detected