MCPcopy Create free account
hub / github.com/boostorg/asio / do_execute

Method do_execute

include/boost/asio/impl/thread_pool.hpp:137–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135template <typename Allocator, unsigned int Bits>
136template <typename Function>
137void thread_pool::basic_executor_type<Allocator,
138 Bits>::do_execute(Function&& f, false_type) const
139{
140 typedef decay_t<Function> function_type;
141
142 // Invoke immediately if the blocking.possibly property is enabled and we are
143 // already inside the thread pool.
144 if ((bits_ & blocking_never) == 0 && pool_->scheduler_.can_dispatch())
145 {
146 // Make a local, non-const copy of the function.
147 function_type tmp(static_cast<Function&&>(f));
148
149#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
150 try
151 {
152#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
153 detail::fenced_block b(detail::fenced_block::full);
154 static_cast<function_type&&>(tmp)();
155 return;
156#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
157 }
158 catch (...)
159 {
160 std::terminate();
161 return;
162 }
163#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
164 }
165
166 // Allocate and construct an operation to wrap the function.
167 typedef detail::executor_op<function_type, Allocator> op;
168 typename op::ptr p = { detail::addressof(allocator_),
169 op::ptr::allocate(allocator_), 0 };
170 p.p = new (p.v) op(static_cast<Function&&>(f), allocator_);
171
172 if ((bits_ & relationship_continuation) != 0)
173 {
174 BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
175 "thread_pool", pool_, 0, "execute(blk=never,rel=cont)"));
176 }
177 else
178 {
179 BOOST_ASIO_HANDLER_CREATION((*pool_, *p.p,
180 "thread_pool", pool_, 0, "execute(blk=never,rel=fork)"));
181 }
182
183 pool_->scheduler_.post_immediate_completion(p.p,
184 (bits_ & relationship_continuation) != 0);
185 p.v = p.p = 0;
186}
187
188template <typename Allocator, unsigned int Bits>
189template <typename Function>

Callers 1

executeMethod · 0.45

Calls 3

allocateFunction · 0.50
waitMethod · 0.45

Tested by

no test coverage detected