1 #ifndef LIBFILEZILLA_THREAD_POOL_HEADER
2 #define LIBFILEZILLA_THREAD_POOL_HEADER
20 class async_task_impl;
41 explicit operator bool()
const {
return impl_ !=
nullptr; }
49 async_task_impl* impl_{};
53 class pooled_thread_impl;
77 FZ_PRIVATE_SYMBOL pooled_thread_impl* get_or_create_thread();
80 friend class pooled_thread_impl;
82 std::vector<pooled_thread_impl*> threads_;
83 std::vector<pooled_thread_impl*> idle_;
Handle for asynchronous tasks.
Definition: thread_pool.hpp:24
void join()
Wait for the task to finish, adds the now idle thread back into the pool.
void detach()
Detach the running thread from the task. Once done, the thread adds itself back into the pool.
~async_task()
If task has not been detached, calls join.
Lean replacement for std::(recursive_)mutex.
Definition: mutex.hpp:52
A dumb thread-pool for asynchronous tasks.
Definition: thread_pool.hpp:64
async_task spawn(std::function< void()> const &f)
Spawns a new asynchronous task.
Sets some global macros and further includes string.hpp.
Thread synchronization primitives: mutex, scoped_lock and condition.
The namespace used by libfilezilla.
Definition: apply.hpp:17