99.34% Lines (150/151) 100.00% Functions (28/28)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
3   // Copyright (c) 2026 Michael Vandeberg 3   // Copyright (c) 2026 Michael Vandeberg
4   // 4   //
5   // Distributed under the Boost Software License, Version 1.0. (See accompanying 5   // Distributed under the Boost Software License, Version 1.0. (See accompanying
6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7   // 7   //
8   // Official repository: https://github.com/boostorg/capy 8   // Official repository: https://github.com/boostorg/capy
9   // 9   //
10   10  
11   #include <boost/capy/ex/thread_pool.hpp> 11   #include <boost/capy/ex/thread_pool.hpp>
12   #include <boost/capy/continuation.hpp> 12   #include <boost/capy/continuation.hpp>
13   #include <boost/capy/detail/thread_local_ptr.hpp> 13   #include <boost/capy/detail/thread_local_ptr.hpp>
14   #include <boost/capy/ex/abandon.hpp> 14   #include <boost/capy/ex/abandon.hpp>
15   #include <boost/capy/ex/frame_allocator.hpp> 15   #include <boost/capy/ex/frame_allocator.hpp>
16   #include <boost/capy/test/thread_name.hpp> 16   #include <boost/capy/test/thread_name.hpp>
17   #include <algorithm> 17   #include <algorithm>
18   #include <atomic> 18   #include <atomic>
19   #include <condition_variable> 19   #include <condition_variable>
20   #include <cstdio> 20   #include <cstdio>
21   #include <mutex> 21   #include <mutex>
22   #include <thread> 22   #include <thread>
23   #include <vector> 23   #include <vector>
24   24  
25   /* 25   /*
26   Thread pool implementation using a shared work queue. 26   Thread pool implementation using a shared work queue.
27   27  
28   Work items are continuations linked via their intrusive next pointer, 28   Work items are continuations linked via their intrusive next pointer,
29   stored in a single queue protected by a mutex. No per-post heap 29   stored in a single queue protected by a mutex. No per-post heap
30   allocation: the continuation is owned by the caller and linked 30   allocation: the continuation is owned by the caller and linked
31   directly. Worker threads wait on a condition_variable until work 31   directly. Worker threads wait on a condition_variable until work
32   is available or stop is requested. 32   is available or stop is requested.
33   33  
34   Threads are started lazily on first post(), under mutex_, to avoid 34   Threads are started lazily on first post(), under mutex_, to avoid
35   spawning threads for pools that are constructed but never used. A 35   spawning threads for pools that are constructed but never used. A
36   stopped pool starts none. Each thread is named 36   stopped pool starts none. Each thread is named
37   with a configurable prefix plus index for debugger visibility. 37   with a configurable prefix plus index for debugger visibility.
38   38  
39   Work tracking: on_work_started/on_work_finished maintain the atomic 39   Work tracking: on_work_started/on_work_finished maintain the atomic
40   outstanding_work_ counter. on_work_started is lock-free, and so is 40   outstanding_work_ counter. on_work_started is lock-free, and so is
41   on_work_finished while the count stays above one. The release that 41   on_work_finished while the count stays above one. The release that
42   may take it to zero is made under mutex_, so join() can't see zero, 42   may take it to zero is made under mutex_, so join() can't see zero,
43   return and let the pool be destroyed while that call still uses it. 43   return and let the pool be destroyed while that call still uses it.
44   join() blocks until this counter reaches zero, then signals workers 44   join() blocks until this counter reaches zero, then signals workers
45   to stop and joins threads. 45   to stop and joins threads.
46   46  
47   Two shutdown paths: 47   Two shutdown paths:
48   - join(): waits for outstanding work to drain, then stops workers. 48   - join(): waits for outstanding work to drain, then stops workers.
49   - stop(): immediately signals workers to exit; queued work stays queued. 49   - stop(): immediately signals workers to exit; queued work stays queued.
50   - Destructor: stop() then join(), then queued work is abandoned. 50   - Destructor: stop() then join(), then queued work is abandoned.
51   */ 51   */
52   52  
53   namespace boost { 53   namespace boost {
54   namespace capy { 54   namespace capy {
55   55  
56   //------------------------------------------------------------------------------ 56   //------------------------------------------------------------------------------
57   57  
58   class thread_pool::impl 58   class thread_pool::impl
59   { 59   {
60   // Identifies the pool owning the current worker thread, or 60   // Identifies the pool owning the current worker thread, or
61   // nullptr if the calling thread is not a pool worker. Checked 61   // nullptr if the calling thread is not a pool worker. Checked
62   // by dispatch() to decide between symmetric transfer (inline 62   // by dispatch() to decide between symmetric transfer (inline
63   // resume) and post. 63   // resume) and post.
64   static inline detail::thread_local_ptr<impl const> current_; 64   static inline detail::thread_local_ptr<impl const> current_;
65   65  
66   // Intrusive queue of continuations: the next link is stored in 66   // Intrusive queue of continuations: the next link is stored in
67   // continuation::reserved (typed continuation* round-tripped through 67   // continuation::reserved (typed continuation* round-tripped through
68   // void*). No per-post allocation: the continuation is owned by the caller. 68   // void*). No per-post allocation: the continuation is owned by the caller.
69   continuation* head_ = nullptr; 69   continuation* head_ = nullptr;
70   continuation* tail_ = nullptr; 70   continuation* tail_ = nullptr;
71   71  
HITCBC 72   22363 void push(continuation* c) noexcept 72   22537 void push(continuation* c) noexcept
73   { 73   {
HITCBC 74   22363 c->reserved = nullptr; 74   22537 c->reserved = nullptr;
HITCBC 75   22363 if(tail_) 75   22537 if(tail_)
HITCBC 76   3303 tail_->reserved = c; 76   1687 tail_->reserved = c;
77   else 77   else
HITCBC 78   19060 head_ = c; 78   20850 head_ = c;
HITCBC 79   22363 tail_ = c; 79   22537 tail_ = c;
HITCBC 80   22363 } 80   22537 }
81   81  
HITCBC 82   25247 continuation* pop() noexcept 82   25389 continuation* pop() noexcept
83   { 83   {
HITCBC 84   25247 if(!head_) 84   25389 if(!head_)
HITCBC 85   2884 return nullptr; 85   2852 return nullptr;
HITCBC 86   22363 continuation* c = head_; 86   22537 continuation* c = head_;
HITCBC 87   22363 head_ = static_cast<continuation*>(head_->reserved); 87   22537 head_ = static_cast<continuation*>(head_->reserved);
HITCBC 88   22363 if(!head_) 88   22537 if(!head_)
HITCBC 89   19060 tail_ = nullptr; 89   20850 tail_ = nullptr;
HITCBC 90   22363 return c; 90   22537 return c;
91   } 91   }
92   92  
HITCBC 93   41113 bool empty() const noexcept 93   43642 bool empty() const noexcept
94   { 94   {
HITCBC 95   41113 return head_ == nullptr; 95   43642 return head_ == nullptr;
96   } 96   }
97   97  
98   std::mutex mutex_; 98   std::mutex mutex_;
99   std::condition_variable work_cv_; 99   std::condition_variable work_cv_;
100   std::condition_variable done_cv_; 100   std::condition_variable done_cv_;
101   std::vector<std::thread> threads_; 101   std::vector<std::thread> threads_;
102   std::atomic<std::size_t> outstanding_work_{0}; 102   std::atomic<std::size_t> outstanding_work_{0};
103   bool stop_{false}; 103   bool stop_{false};
104   bool joined_{false}; 104   bool joined_{false};
105   std::size_t num_threads_; 105   std::size_t num_threads_;
106   char thread_name_prefix_[13]{}; // 12 chars max + null terminator 106   char thread_name_prefix_[13]{}; // 12 chars max + null terminator
107   std::atomic<bool> started_{false}; 107   std::atomic<bool> started_{false};
108   108  
109   public: 109   public:
HITCBC 110   1442 ~impl() = default; 110   1426 ~impl() = default;
111   111  
112   bool 112   bool
HITCBC 113   3223 running_in_this_thread() const noexcept 113   3204 running_in_this_thread() const noexcept
114   { 114   {
HITCBC 115   3223 return current_.get() == this; 115   3204 return current_.get() == this;
116   } 116   }
117   117  
118   // Abandon queued coroutines. Each is taken under the lock, as other 118   // Abandon queued coroutines. Each is taken under the lock, as other
119   // threads may still post, and abandoned outside it, as abandoning 119   // threads may still post, and abandoned outside it, as abandoning
120   // can post. 120   // can post.
121   void 121   void
HITCBC 122   2884 drain_abandoned() noexcept 122   2852 drain_abandoned() noexcept
123   { 123   {
124   for(;;) 124   for(;;)
125   { 125   {
126   continuation* c; 126   continuation* c;
127   { 127   {
HITCBC 128   3411 std::lock_guard<std::mutex> lock(mutex_); 128   3393 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 129   3411 c = pop(); 129   3393 c = pop();
HITCBC 130   3411 } 130   3393 }
HITCBC 131   3411 if(!c) 131   3393 if(!c)
HITCBC 132   2884 return; 132   2852 return;
HITCBC 133   527 if(c->h && c->h != std::noop_coroutine()) 133   541 if(c->h && c->h != std::noop_coroutine())
HITCBC 134   274 capy::abandon(*c); 134   278 capy::abandon(*c);
HITCBC 135   527 } 135   541 }
136   } 136   }
137   137  
HITCBC 138   1442 impl(std::size_t num_threads, std::string_view thread_name_prefix) 138   1426 impl(std::size_t num_threads, std::string_view thread_name_prefix)
HITCBC 139   1442 : num_threads_(num_threads) 139   1426 : num_threads_(num_threads)
140   { 140   {
HITCBC 141   1442 if(num_threads_ == 0) 141   1426 if(num_threads_ == 0)
HITCBC 142   8 num_threads_ = std::max( 142   8 num_threads_ = std::max(
HITCBC 143   4 std::thread::hardware_concurrency(), 1u); 143   4 std::thread::hardware_concurrency(), 1u);
144   144  
145   // Truncate prefix to 12 chars, leaving room for up to 3-digit index. 145   // Truncate prefix to 12 chars, leaving room for up to 3-digit index.
HITCBC 146   1442 auto n = thread_name_prefix.copy(thread_name_prefix_, 12); 146   1426 auto n = thread_name_prefix.copy(thread_name_prefix_, 12);
HITCBC 147   1442 thread_name_prefix_[n] = '\0'; 147   1426 thread_name_prefix_[n] = '\0';
HITCBC 148   1442 } 148   1426 }
149   149  
150   void 150   void
HITCBC 151   22365 post(continuation& c) 151   22539 post(continuation& c)
152   { 152   {
HITCBC 153   22365 if(!started_.load(std::memory_order_acquire)) 153   22539 if(!started_.load(std::memory_order_acquire))
154   { 154   {
155   { 155   {
HITCBC 156   607 std::lock_guard<std::mutex> lock(mutex_); 156   591 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 157   607 if(stop_) 157   591 if(stop_)
158   { 158   {
159   // Stopped before any thread started: nothing will 159   // Stopped before any thread started: nothing will
160   // run it, and the destructor's drain abandons it. 160   // run it, and the destructor's drain abandons it.
HITCBC 161   220 push(&c); 161   220 push(&c);
HITCBC 162   220 return; 162   220 return;
163   } 163   }
HITCBC 164   607 } 164   591 }
HITCBC 165   387 ensure_started(); 165   371 ensure_started();
166   } 166   }
HITCBC 167   22143 std::lock_guard<std::mutex> lock(mutex_); 167   22317 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 168   22143 push(&c); 168   22317 push(&c);
169   // Under the lock so the pool cannot drain, join, and 169   // Under the lock so the pool cannot drain, join, and
170   // destroy the condition variable mid-signal. 170   // destroy the condition variable mid-signal.
HITCBC 171   22143 work_cv_.notify_one(); 171   22317 work_cv_.notify_one();
HITCBC 172   22143 } 172   22317 }
173   173  
174   void 174   void
HITCBC 175   4100 on_work_started() noexcept 175   4084 on_work_started() noexcept
176   { 176   {
HITCBC 177   4100 outstanding_work_.fetch_add(1, std::memory_order_acq_rel); 177   4084 outstanding_work_.fetch_add(1, std::memory_order_acq_rel);
HITCBC 178   4100 } 178   4084 }
179   179  
180   void 180   void
HITCBC 181   3800 on_work_finished() noexcept 181   3784 on_work_finished() noexcept
182   { 182   {
HITCBC 183   3800 auto n = outstanding_work_.load(std::memory_order_relaxed); 183   3784 auto n = outstanding_work_.load(std::memory_order_relaxed);
HITCBC 184   3806 while(n > 1) 184   3792 while(n > 1)
185   { 185   {
HITCBC 186   2896 if(outstanding_work_.compare_exchange_weak( 186   1292 if(outstanding_work_.compare_exchange_weak(
187   n, n - 1, std::memory_order_acq_rel)) 187   n, n - 1, std::memory_order_acq_rel))
HITCBC 188   1442 return; 188   638 return;
189   } 189   }
HITCBC 190   2358 std::lock_guard<std::mutex> lock(mutex_); 190   3146 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 191   2358 outstanding_work_.fetch_sub(1, std::memory_order_acq_rel); 191   3146 outstanding_work_.fetch_sub(1, std::memory_order_acq_rel);
192   // Re-read: a concurrent on_work_started() may have raised it. 192   // Re-read: a concurrent on_work_started() may have raised it.
HITCBC 193   2358 if(outstanding_work_.load( 193   3146 if(outstanding_work_.load(
HITCBC 194   2358 std::memory_order_acquire) == 0 && joined_ && !stop_) 194   3146 std::memory_order_acquire) == 0 && joined_ && !stop_)
195   { 195   {
HITCBC 196   712 stop_ = true; 196   706 stop_ = true;
HITCBC 197   712 done_cv_.notify_all(); 197   706 done_cv_.notify_all();
HITCBC 198   712 work_cv_.notify_all(); 198   706 work_cv_.notify_all();
199   } 199   }
HITCBC 200   2358 } 200   3146 }
201   201  
202   void 202   void
HITCBC 203   2741 join() noexcept 203   2713 join() noexcept
204   { 204   {
205   { 205   {
HITCBC 206   2741 std::unique_lock<std::mutex> lock(mutex_); 206   2713 std::unique_lock<std::mutex> lock(mutex_);
HITCBC 207   2741 if(joined_) 207   2713 if(joined_)
HITCBC 208   1299 return; 208   1287 return;
HITCBC 209   1442 joined_ = true; 209   1426 joined_ = true;
210   210  
HITCBC 211   1442 if(outstanding_work_.load( 211   1426 if(outstanding_work_.load(
HITCBC 212   1442 std::memory_order_acquire) == 0) 212   1426 std::memory_order_acquire) == 0)
213   { 213   {
HITCBC 214   372 stop_ = true; 214   364 stop_ = true;
HITCBC 215   372 work_cv_.notify_all(); 215   364 work_cv_.notify_all();
216   } 216   }
217   else 217   else
218   { 218   {
HITCBC 219   1070 done_cv_.wait(lock, [this]{ 219   1062 done_cv_.wait(lock, [this]{
HITCBC 220   2083 return stop_; 220   2069 return stop_;
221   }); 221   });
222   } 222   }
HITCBC 223   2741 } 223   2713 }
224   224  
HITCBC 225   1954 for(auto& t : threads_) 225   1919 for(auto& t : threads_)
HITCBC 226   512 if(t.joinable()) 226   493 if(t.joinable())
HITCBC 227   512 t.join(); 227   493 t.join();
228   } 228   }
229   229  
230   void 230   void
HITCBC 231   1745 stop() noexcept 231   1729 stop() noexcept
232   { 232   {
233   // Under the lock: the join() this releases may return and let 233   // Under the lock: the join() this releases may return and let
234   // the pool be destroyed as soon as the lock is free. 234   // the pool be destroyed as soon as the lock is free.
HITCBC 235   1745 std::lock_guard<std::mutex> lock(mutex_); 235   1729 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 236   1745 stop_ = true; 236   1729 stop_ = true;
HITCBC 237   1745 work_cv_.notify_all(); 237   1729 work_cv_.notify_all();
HITCBC 238   1745 done_cv_.notify_all(); 238   1729 done_cv_.notify_all();
HITCBC 239   1745 } 239   1729 }
240   240  
241   private: 241   private:
242   void 242   void
HITCBC 243   387 ensure_started() 243   371 ensure_started()
244   { 244   {
245   // Under the lock, so join() either sees every thread started 245   // Under the lock, so join() either sees every thread started
246   // here or makes this start none. A joined pool still starts them: 246   // here or makes this start none. A joined pool still starts them:
247   // join() may be waiting on work that needs them. 247   // join() may be waiting on work that needs them.
HITCBC 248   387 std::lock_guard<std::mutex> lock(mutex_); 248   371 std::lock_guard<std::mutex> lock(mutex_);
HITCBC 249   387 if(started_.load(std::memory_order_relaxed) || stop_) 249   371 if(started_.load(std::memory_order_relaxed) || stop_)
MISUBC 250   ✗ return; 250   ✗ return;
251   // Start at the threads already running: if an earlier call 251   // Start at the threads already running: if an earlier call
252   // threw partway, this one adds only the missing ones. 252   // threw partway, this one adds only the missing ones.
HITCBC 253   387 threads_.reserve(num_threads_); 253   371 threads_.reserve(num_threads_);
HITCBC 254   899 for(std::size_t i = threads_.size(); i < num_threads_; ++i) 254   864 for(std::size_t i = threads_.size(); i < num_threads_; ++i)
HITCBC 255   1026 threads_.emplace_back([this, i]{ run(i); }); 255   988 threads_.emplace_back([this, i]{ run(i); });
HITCBC 256   385 started_.store(true, std::memory_order_release); 256   369 started_.store(true, std::memory_order_release);
HITCBC 257   387 } 257   371 }
258   258  
259   void 259   void
HITCBC 260   512 run(std::size_t index) 260   493 run(std::size_t index)
261   { 261   {
262   // Build name; set_current_thread_name truncates to platform limits. 262   // Build name; set_current_thread_name truncates to platform limits.
263   char name[16]; 263   char name[16];
HITCBC 264   512 std::snprintf(name, sizeof(name), "%s%zu", thread_name_prefix_, index); 264   493 std::snprintf(name, sizeof(name), "%s%zu", thread_name_prefix_, index);
HITCBC 265   512 set_current_thread_name(name); 265   493 set_current_thread_name(name);
266   266  
267   // Mark this thread as a worker of this pool so dispatch() 267   // Mark this thread as a worker of this pool so dispatch()
268   // can symmetric-transfer when called from within pool work. 268   // can symmetric-transfer when called from within pool work.
269   struct scoped_pool 269   struct scoped_pool
270   { 270   {
HITCBC 271   512 scoped_pool(impl const* p) noexcept { current_.set(p); } 271   493 scoped_pool(impl const* p) noexcept { current_.set(p); }
HITCBC 272   512 ~scoped_pool() noexcept { current_.set(nullptr); } 272   493 ~scoped_pool() noexcept { current_.set(nullptr); }
HITCBC 273   512 } guard(this); 273   493 } guard(this);
274   274  
275   for(;;) 275   for(;;)
276   { 276   {
HITCBC 277   22348 continuation* c = nullptr; 277   22489 continuation* c = nullptr;
278   { 278   {
HITCBC 279   22348 std::unique_lock<std::mutex> lock(mutex_); 279   22489 std::unique_lock<std::mutex> lock(mutex_);
HITCBC 280   22348 work_cv_.wait(lock, [this]{ 280   22489 work_cv_.wait(lock, [this]{
HITCBC 281   60285 return !empty() || 281   65185 return !empty() ||
HITCBC 282   60285 stop_; 282   65185 stop_;
283   }); 283   });
HITCBC 284   22348 if(stop_) 284   22489 if(stop_)
HITCBC 285   1024 return; 285   986 return;
HITCBC 286   21836 c = pop(); 286   21996 c = pop();
HITCBC 287   22348 } 287   22489 }
HITCBC 288   21836 if(c) 288   21996 if(c)
HITCBC 289   21836 safe_resume(c->h); 289   21996 safe_resume(c->h);
HITCBC 290   21836 } 290   21996 }
HITCBC 291   512 } 291   493 }
292   }; 292   };
293   293  
294   //------------------------------------------------------------------------------ 294   //------------------------------------------------------------------------------
295   295  
HITCBC 296   1442 thread_pool:: 296   1426 thread_pool::
297   ~thread_pool() 297   ~thread_pool()
298   { 298   {
HITCBC 299   1442 impl_->stop(); 299   1426 impl_->stop();
HITCBC 300   1442 impl_->join(); 300   1426 impl_->join();
HITCBC 301   1442 shutdown(); 301   1426 shutdown();
302   // Takes what the unwinds post too, and the work of any service they 302   // Takes what the unwinds post too, and the work of any service they
303   // create, which is shut down as it is created. 303   // create, which is shut down as it is created.
HITCBC 304   1442 impl_->drain_abandoned(); 304   1426 impl_->drain_abandoned();
HITCBC 305   1442 destroy(); 305   1426 destroy();
306   // Services give up their work in shutdown(), but anything a 306   // Services give up their work in shutdown(), but anything a
307   // destructor posts anyway is still destroyed. 307   // destructor posts anyway is still destroyed.
HITCBC 308   1442 impl_->drain_abandoned(); 308   1426 impl_->drain_abandoned();
HITCBC 309   1442 delete impl_; 309   1426 delete impl_;
HITCBC 310   1442 } 310   1426 }
311   311  
HITCBC 312   1442 thread_pool:: 312   1426 thread_pool::
HITCBC 313   1442 thread_pool(std::size_t num_threads, std::string_view thread_name_prefix) 313   1426 thread_pool(std::size_t num_threads, std::string_view thread_name_prefix)
HITCBC 314   1442 : impl_(new impl(num_threads, thread_name_prefix)) 314   1426 : impl_(new impl(num_threads, thread_name_prefix))
315   { 315   {
HITCBC 316   1442 this->set_frame_allocator(std::allocator<void>{}); 316   1426 this->set_frame_allocator(std::allocator<void>{});
HITCBC 317   1442 } 317   1426 }
318   318  
319   void 319   void
HITCBC 320   1299 thread_pool:: 320   1287 thread_pool::
321   join() noexcept 321   join() noexcept
322   { 322   {
HITCBC 323   1299 impl_->join(); 323   1287 impl_->join();
HITCBC 324   1299 } 324   1287 }
325   325  
326   void 326   void
HITCBC 327   303 thread_pool:: 327   303 thread_pool::
328   stop() noexcept 328   stop() noexcept
329   { 329   {
HITCBC 330   303 impl_->stop(); 330   303 impl_->stop();
HITCBC 331   303 } 331   303 }
332   332  
333   //------------------------------------------------------------------------------ 333   //------------------------------------------------------------------------------
334   334  
335   thread_pool::executor_type 335   thread_pool::executor_type
HITCBC 336   15361 thread_pool:: 336   15345 thread_pool::
337   get_executor() const noexcept 337   get_executor() const noexcept
338   { 338   {
HITCBC 339   15361 return executor_type( 339   15345 return executor_type(
HITCBC 340   15361 const_cast<thread_pool&>(*this)); 340   15345 const_cast<thread_pool&>(*this));
341   } 341   }
342   342  
343   void 343   void
HITCBC 344   4100 thread_pool::executor_type:: 344   4084 thread_pool::executor_type::
345   on_work_started() const noexcept 345   on_work_started() const noexcept
346   { 346   {
HITCBC 347   4100 pool_->impl_->on_work_started(); 347   4084 pool_->impl_->on_work_started();
HITCBC 348   4100 } 348   4084 }
349   349  
350   void 350   void
HITCBC 351   3800 thread_pool::executor_type:: 351   3784 thread_pool::executor_type::
352   on_work_finished() const noexcept 352   on_work_finished() const noexcept
353   { 353   {
HITCBC 354   3800 pool_->impl_->on_work_finished(); 354   3784 pool_->impl_->on_work_finished();
HITCBC 355   3800 } 355   3784 }
356   356  
357   void 357   void
HITCBC 358   19149 thread_pool::executor_type:: 358   19339 thread_pool::executor_type::
359   post(continuation& c) const 359   post(continuation& c) const
360   { 360   {
HITCBC 361   19149 pool_->impl_->post(c); 361   19339 pool_->impl_->post(c);
HITCBC 362   19147 } 362   19337 }
363   363  
364   std::coroutine_handle<> 364   std::coroutine_handle<>
HITCBC 365   3223 thread_pool::executor_type:: 365   3204 thread_pool::executor_type::
366   dispatch(continuation& c) const 366   dispatch(continuation& c) const
367   { 367   {
HITCBC 368   3223 if(pool_->impl_->running_in_this_thread()) 368   3204 if(pool_->impl_->running_in_this_thread())
HITCBC 369   7 return c.h; 369   4 return c.h;
HITCBC 370   3216 pool_->impl_->post(c); 370   3200 pool_->impl_->post(c);
HITCBC 371   3216 return std::noop_coroutine(); 371   3200 return std::noop_coroutine();
372   } 372   }
373   373  
374   } // capy 374   } // capy
375   } // boost 375   } // boost