FC Updates from BitShares and myself #21
5 changed files with 8 additions and 6 deletions
|
|
@ -49,7 +49,7 @@ namespace fc {
|
||||||
private:
|
private:
|
||||||
class ticket_guard {
|
class ticket_guard {
|
||||||
public:
|
public:
|
||||||
ticket_guard( boost::atomic<future<void>*>& latch );
|
explicit ticket_guard( boost::atomic<future<void>*>& latch );
|
||||||
~ticket_guard();
|
~ticket_guard();
|
||||||
void wait_for_my_turn();
|
void wait_for_my_turn();
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ namespace fc {
|
||||||
*/
|
*/
|
||||||
class thread_idle_notifier {
|
class thread_idle_notifier {
|
||||||
public:
|
public:
|
||||||
|
virtual ~thread_idle_notifier() {}
|
||||||
|
|
||||||
/** This method is called when the thread is idle. If it returns a
|
/** This method is called when the thread is idle. If it returns a
|
||||||
* task_base it will be queued and executed immediately.
|
* task_base it will be queued and executed immediately.
|
||||||
* @return a task to execute, or nullptr
|
* @return a task to execute, or nullptr
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ namespace fc {
|
||||||
{
|
{
|
||||||
// the default was not set by the configuration. Determine a good
|
// the default was not set by the configuration. Determine a good
|
||||||
// number of threads. Minimum of 8, maximum of hardware_concurrency
|
// number of threads. Minimum of 8, maximum of hardware_concurrency
|
||||||
num_io_threads = std::max( boost::thread::hardware_concurrency(), 8u );
|
num_io_threads = std::max( boost::thread::hardware_concurrency(), 8U );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( uint16_t i = 0; i < num_io_threads; ++i )
|
for( uint16_t i = 0; i < num_io_threads; ++i )
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,6 @@
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
class pool_impl;
|
|
||||||
|
|
||||||
class idle_notifier_impl : public thread_idle_notifier
|
class idle_notifier_impl : public thread_idle_notifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -49,6 +47,8 @@ namespace fc {
|
||||||
is_idle.store( copy.is_idle.load() );
|
is_idle.store( copy.is_idle.load() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~idle_notifier_impl() {}
|
||||||
|
|
||||||
virtual task_base* idle();
|
virtual task_base* idle();
|
||||||
virtual void busy()
|
virtual void busy()
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +63,7 @@ namespace fc {
|
||||||
class pool_impl
|
class pool_impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pool_impl( const uint16_t num_threads )
|
explicit pool_impl( const uint16_t num_threads )
|
||||||
: idle_threads( 2 * num_threads ), waiting_tasks( 200 )
|
: idle_threads( 2 * num_threads ), waiting_tasks( 200 )
|
||||||
{
|
{
|
||||||
notifiers.resize( num_threads );
|
notifiers.resize( num_threads );
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace fc {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
class idle_guard {
|
class idle_guard {
|
||||||
public:
|
public:
|
||||||
idle_guard( thread_d* t );
|
explicit idle_guard( thread_d* t );
|
||||||
~idle_guard();
|
~idle_guard();
|
||||||
private:
|
private:
|
||||||
thread_idle_notifier* notifier;
|
thread_idle_notifier* notifier;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue