@@ -36,18 +36,23 @@ class ThreadPoolImpl
3636 ThreadPoolImpl (size_t max_threads_, size_t max_free_threads_, size_t queue_size_);
3737
3838 // / Add new job. Locks until number of scheduled jobs is less than maximum or exception in one of threads was thrown.
39- // / If an exception in some thread was thrown, method silently returns, and exception will be rethrown only on call to 'wait' function.
39+ // / If any thread was throw an exception, first exception will be rethrown from this method,
40+ // / and exception will be cleared.
41+ // / Also throws an exception if cannot create thread.
4042 // / Priority: greater is higher.
41- void schedule (Job job, int priority = 0 );
43+ // / NOTE: Probably you should call wait() if exception was thrown. If some previously scheduled jobs are using some objects,
44+ // / located on stack of current thread, the stack must not be unwinded until all jobs finished. However,
45+ // / if ThreadPool is a local object, it will wait for all scheduled jobs in own destructor.
46+ void scheduleOrThrowOnError (Job job, int priority = 0 );
4247
43- // / Wait for specified amount of time and schedule a job or return false.
44- bool trySchedule (Job job, int priority = 0 , uint64_t wait_microseconds = 0 );
48+ // / Similar to scheduleOrThrowOnError(...). Wait for specified amount of time and schedule a job or return false.
49+ bool trySchedule (Job job, int priority = 0 , uint64_t wait_microseconds = 0 ) noexcept ;
4550
46- // / Wait for specified amount of time and schedule a job or throw an exception.
51+ // / Similar to scheduleOrThrowOnError(...). Wait for specified amount of time and schedule a job or throw an exception.
4752 void scheduleOrThrow (Job job, int priority = 0 , uint64_t wait_microseconds = 0 );
4853
4954 // / Wait for all currently active jobs to be done.
50- // / You may call schedule and wait many times in arbitary order.
55+ // / You may call schedule and wait many times in arbitrary order.
5156 // / If any thread was throw an exception, first exception will be rethrown from this method,
5257 // / and exception will be cleared.
5358 void wait ();
@@ -140,7 +145,7 @@ class ThreadFromGlobalPool
140145 explicit ThreadFromGlobalPool (Function && func, Args &&... args)
141146 : state(std::make_shared<Poco::Event>())
142147 {
143- // / NOTE: If this will throw an exception, the descructor won't be called.
148+ // / NOTE: If this will throw an exception, the destructor won't be called.
144149 GlobalThreadPool::instance ().scheduleOrThrow ([
145150 state = state,
146151 func = std::forward<Function>(func),
0 commit comments