void trampoline( typename worker_fiber::coro_t::yield_type & yield) { BOOST_ASSERT( yield); void * p( yield.get() ); BOOST_ASSERT( p); setup< Fn > * from( static_cast< setup< Fn > * >( p) ); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES Fn fn_( forward< Fn >( from->fn) ); #else Fn fn_( move( from->fn) ); #endif worker_fiber f( & yield); from->f = & f; f.set_running(); f.suspend(); try { #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES Fn fn( forward< Fn >( fn_) ); #else Fn fn( move( fn_) ); #endif BOOST_ASSERT( f.is_running() ); fn(); BOOST_ASSERT( f.is_running() ); } catch ( coro::detail::forced_unwind const&) { f.set_terminated(); f.release(); throw; } catch ( fiber_interrupted const&) { f.set_exception( current_exception() ); } catch (...) { std::terminate(); } f.set_terminated(); f.release(); f.suspend(); BOOST_ASSERT_MSG( false, "fiber already terminated"); }
void run(Args&&... args) { try { this->set_value(fn_(std::forward<Args>(args)...)); } catch(...) { this->set_exception(std::current_exception()); } }
void debuger_thread_runner::start() { if (fn_) { fn_(argc_, argv_); } finished(); }
bool eval() const { if (terminate_) return true; if (period_ > 0.0) return evalValue_; return fn_(); }
T& operator=(const T& d) { if (data_ != d && fn_) fn_(d); data_ = d; return data_; }
void load(Archive & ar, const unsigned int version) { T d = data_; ar & boost::serialization::make_nvp("data", d); if (data_ != d && fn_) fn_(d); data_ = d; }
void CoTimer::operator()() { std::unique_lock<LFLock> lock(fn_lock_, std::defer_lock); if (!lock.try_lock()) return ; // below statement was locked. if (!active_) return ; active_ = false; fn_(); }
void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) { gBytesProcessed = 0; gBenchmarkTotalTimeNs = 0; gBenchmarkStartTimeNs = NanoTime(); if (fn_ != NULL) { fn_(iterations); } else { fn_range_(iterations, arg); } if (gBenchmarkStartTimeNs != 0) { gBenchmarkTotalTimeNs += NanoTime() - gBenchmarkStartTimeNs; } }
void Loop::eventLoop(unsigned long long step) { std::map<std::string,Module*>::iterator itMd; for(itMd=moduleMap_.begin();itMd!=moduleMap_.end();++itMd){ itMd->second->init(); } while(1){ fn_(step_); step_++; //do method std::list<Module*>::iterator it; Module *md; for(it=eventList_.begin();it!=eventList_.end();it++){ md=*it; md->method(); } eventList_.clear(); if(step_==step) break; } }
/** \brief Worker function that runs in a separate thread (calls computeEval())*/ void periodicEval() { // we want to check for termination at least once every ms; // even though we may evaluate the condition itself more rarely unsigned int count = 1; time::duration s = time::seconds(period_); if (period_ > 0.001) { count = 0.5 + period_ / 0.001; s = time::seconds(period_ / (double) count); } while (!terminate_ && !signalThreadStop_) { evalValue_ = fn_(); for (unsigned int i = 0 ; i < count ; ++i) { if (terminate_ || signalThreadStop_) break; boost::this_thread::sleep(s); } } }
pixel_t operator()(const coord_t x, const coord_t y) const { return fn_(base_(x, y)); }
void EventBase::RunInLoopCallback::runLoopCallback() noexcept { fn_(arg_); delete this; }
float Tweener::out_value() const { return fn_(in_value()); }
node node::operator()(node args) { ASSERT_LOG(type() == NODE_TYPE_FUNCTION, "Tried to execute node that wasn't a function, was: " << type_as_string()); return fn_(args); }
void fn_command_callable_arg::execute(formula_callable& context) const { fn_(&context); }
void submit(lua_State* L) { fn_(L, this); }
virtual bool isValid(const State *state) const { return fn_(state); }
bool isValid(const State *state) const override { return fn_(state); }
void propagate(const base::State *state, const Control *control, const double duration, base::State *result) const override { fn_(state, control, duration, result); }
void PostTask::operator ()() { fn_(); }
void draw(paint::graphics& graph) const { fn_(graph); }