示例#1
0
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_();
 }
示例#5
0
文件: halConfig.hpp 项目: OV2/Halite
	T& operator=(const T& d) 
	{	
		if (data_ != d && fn_)
			fn_(d);

		data_ = d;

		return data_;
	}
示例#6
0
文件: halConfig.hpp 项目: OV2/Halite
	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;
	}
示例#7
0
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_();
}
示例#8
0
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;
  }
}
示例#9
0
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);
                    }
                }
            }
示例#11
0
 pixel_t operator()(const coord_t x, const coord_t y) const {
     return fn_(base_(x, y));
 }
示例#12
0
void EventBase::RunInLoopCallback::runLoopCallback() noexcept {
  fn_(arg_);
  delete this;
}
示例#13
0
float Tweener::out_value() const
{
    return fn_(in_value());
}
示例#14
0
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);
}
示例#15
0
void fn_command_callable_arg::execute(formula_callable& context) const
{
	fn_(&context);
}
示例#16
0
 void submit(lua_State* L)
 { fn_(L, this); }
示例#17
0
 virtual bool isValid(const State *state) const
 {
     return fn_(state);
 }
示例#18
0
 bool isValid(const State *state) const override
 {
     return fn_(state);
 }
示例#19
0
 void propagate(const base::State *state, const Control *control, const double duration,
                base::State *result) const override
 {
     fn_(state, control, duration, result);
 }
示例#20
0
文件: Task.cpp 项目: nitric1/Maragi
 void PostTask::operator ()()
 {
     fn_();
 }
示例#21
0
		void draw(paint::graphics& graph) const
		{
			fn_(graph);
		}