2012-09-08 02:50:37 +00:00
|
|
|
#include <fc/task.hpp>
|
|
|
|
|
#include <fc/exception.hpp>
|
|
|
|
|
#include <fc/unique_lock.hpp>
|
|
|
|
|
#include <fc/spin_lock.hpp>
|
2012-09-09 23:44:49 +00:00
|
|
|
#include <fc/fwd_impl.hpp>
|
|
|
|
|
|
2012-09-08 02:50:37 +00:00
|
|
|
|
|
|
|
|
namespace fc {
|
|
|
|
|
task_base::task_base(void* func)
|
|
|
|
|
:_functor(func){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void task_base::run() {
|
|
|
|
|
try {
|
|
|
|
|
_run_functor( _functor, _promise_impl );
|
|
|
|
|
} catch ( ... ) {
|
2012-09-09 23:44:49 +00:00
|
|
|
set_exception( current_exception() );
|
2012-09-08 02:50:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
task_base::~task_base() {
|
|
|
|
|
_destroy_functor( _functor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void task_base::_set_active_context(context* c) {
|
2012-09-09 23:44:49 +00:00
|
|
|
{ synchronized( *_spinlock )
|
2012-09-08 02:50:37 +00:00
|
|
|
_active_context = c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|