Mercury Currency Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mce::threadpool Struct Reference

#include <threadpool.hpp>

Inheritance diagram for mce::threadpool:
Inheritance graph
[legend]
Collaboration diagram for mce::threadpool:
Collaboration graph
[legend]

Public Member Functions

virtual ~threadpool ()
 halt(), join() and delete all workers
 
size_t size () const
 return the count of worker threads
 
schedulerworker (size_t idx) const
 access the scheduler for a worker at a given index
 
schedulerworker ()
 return the least busy worker scheduler at time of call
 
std::vector< std::shared_ptr< scheduler > > workers ()
 
 operator std::shared_ptr< threadpool > ()
 return a copy of this threadpool's shared pointer by conversion
 
- Public Member Functions inherited from mce::lifecycle
 lifecycle (implementation *self)
 
 lifecycle (implementation *self, implementation *root)
 
state get_state ()
 return the state of the lifecycle
 
bool suspend ()
 temporarily suspend operations More...
 
void resume ()
 resume any current or future call to run() after an suspend()
 
void halt ()
 halt and join lifecycle execution More...
 

Static Public Member Functions

static std::shared_ptr< threadpoolmake (size_t worker_count=0)
 construct an allocated threadpool with a count of worker threads
 

Protected Member Functions

lifecycle::state get_state_impl ()
 
bool suspend_impl ()
 
void resume_impl ()
 
void halt_impl ()
 

Additional Inherited Members

- Public Types inherited from mce::lifecycle
enum  state { ready , running , suspended , halted }
 an enumeration which represents the lifecycle object's current state More...
 

Detailed Description

Threadpool objects launch, maintain, and shutdown worker threads running schedulers

Member Function Documentation

◆ workers()

std::vector<std::shared_ptr<scheduler> > mce::threadpool::workers ( )
inline

This operation is more expensive than calling worker(). It should be unnecessary in most cases to call this method, but it is provided in case some sort of high level scheduler management is desired by the user and access to all of std::vector's utility functionality would be beneficial.

Returns
the schedulers for all running worker threads

The documentation for this struct was generated from the following file: