mirror of
https://github.com/BlackMATov/promise.hpp.git
synced 2025-12-15 12:29:50 +07:00
extract jobber thread ids
This commit is contained in:
@@ -58,6 +58,10 @@ namespace jobber_hpp
|
|||||||
void resume() noexcept;
|
void resume() noexcept;
|
||||||
bool is_paused() const noexcept;
|
bool is_paused() const noexcept;
|
||||||
|
|
||||||
|
std::size_t thread_count() const noexcept;
|
||||||
|
std::thread::id thread_id(std::size_t i) const;
|
||||||
|
std::vector<std::thread::id> thread_ids() const;
|
||||||
|
|
||||||
jobber_wait_status wait_all() const noexcept;
|
jobber_wait_status wait_all() const noexcept;
|
||||||
active_wait_result_t active_wait_all() noexcept;
|
active_wait_result_t active_wait_all() noexcept;
|
||||||
active_wait_result_t active_wait_one() noexcept;
|
active_wait_result_t active_wait_one() noexcept;
|
||||||
@@ -189,6 +193,23 @@ namespace jobber_hpp
|
|||||||
return paused_;
|
return paused_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::size_t jobber::thread_count() const noexcept {
|
||||||
|
return threads_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::thread::id jobber::thread_id(std::size_t i) const {
|
||||||
|
return threads_[i].get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<std::thread::id> jobber::thread_ids() const {
|
||||||
|
std::vector<std::thread::id> ids;
|
||||||
|
ids.reserve(threads_.size());
|
||||||
|
for ( const std::thread& t : threads_ ) {
|
||||||
|
ids.push_back(t.get_id());
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
inline jobber_wait_status jobber::wait_all() const noexcept {
|
inline jobber_wait_status jobber::wait_all() const noexcept {
|
||||||
std::unique_lock<std::mutex> lock(tasks_mutex_);
|
std::unique_lock<std::mutex> lock(tasks_mutex_);
|
||||||
cond_var_.wait(lock, [this](){
|
cond_var_.wait(lock, [this](){
|
||||||
|
|||||||
Reference in New Issue
Block a user