FC Updates from BitShares and myself #21
2 changed files with 9 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ namespace fc {
|
|||
|
||||
namespace detail
|
||||
{
|
||||
class pool_impl;
|
||||
class worker_pool;
|
||||
void* get_thread_specific_data(unsigned slot);
|
||||
void set_thread_specific_data(unsigned slot, void* new_value, void(*cleanup)(void*));
|
||||
unsigned get_next_unused_task_storage_slot();
|
||||
|
|
@ -152,7 +152,7 @@ namespace fc {
|
|||
friend class task_base;
|
||||
friend class thread_d;
|
||||
friend class mutex;
|
||||
friend class detail::pool_impl;
|
||||
friend class detail::worker_pool;
|
||||
friend void* detail::get_thread_specific_data(unsigned slot);
|
||||
friend void detail::set_thread_specific_data(unsigned slot, void* new_value, void(*cleanup)(void*));
|
||||
friend unsigned detail::get_next_unused_task_storage_slot();
|
||||
|
|
|
|||
|
|
@ -84,24 +84,23 @@ namespace fc {
|
|||
});
|
||||
}
|
||||
|
||||
void post( task_base* task )
|
||||
thread* post( task_base* task )
|
||||
{
|
||||
idle_notifier_impl* ini;
|
||||
while( idle_threads.pop( ini ) )
|
||||
if( ini->is_idle.exchange( false ) )
|
||||
{ // minor race condition here, a thread might receive a task while it's busy
|
||||
threads[ini->id]->async_task( task, priority() );
|
||||
return;
|
||||
return threads[ini->id];
|
||||
}
|
||||
boost::unique_lock<fc::spin_yield_lock> lock(pool_lock);
|
||||
while( idle_threads.pop( ini ) )
|
||||
if( ini->is_idle.exchange( false ) )
|
||||
{ // minor race condition here, a thread might receive a task while it's busy
|
||||
threads[ini->id]->async_task( task, priority() );
|
||||
return;
|
||||
return threads[ini->id];
|
||||
}
|
||||
while( !waiting_tasks.push( task ) )
|
||||
elog( "Worker pool internal error" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
task_base* enqueue_idle_thread( idle_notifier_impl* ini )
|
||||
|
|
@ -145,7 +144,9 @@ namespace fc {
|
|||
|
||||
void worker_pool::post( task_base* task )
|
||||
{
|
||||
my->post( task );
|
||||
thread* worker = my->post( task );
|
||||
if( worker )
|
||||
worker->async_task( task, priority() );
|
||||
}
|
||||
|
||||
worker_pool& get_worker_pool()
|
||||
|
|
|
|||
Loading…
Reference in a new issue