-
Notifications
You must be signed in to change notification settings - Fork 4
Namespace::Thread
Bae jiun, Maybe edited this page Dec 26, 2017
·
1 revision
namespace thread
implementation
Implemented in pool.hpp
.
A nice and simple thread pool that supports C++ standard threads. With std::future
, you can infer the expected type of result ahead of time when the job is added, and you can get the job done and get the results. When the task is added, parameters can be seamlessly executed in shared memory via std::bind
, std::packaged_task
, and std::shared_ptr
. You can also add a task that takes a thread_id as an argument.
methods
-
std::future<> push(F&& f, Args&&… args)
std::bind
and package the given function and arguments at the point of adding the work, and pass it to the worker who made it beforehand. Once the operation is done through the returnedstd::future
, you can get the result. -
std::future<void> push(F&&f)
Same as above method overload, butf
have thread_id as argument typesize_t
. And can't pass no other arguments. It's do not make sense bind withsize_t
(thread id) with origin arguments. So if you need, pass through lambda capture.