Example #1
0
 //恢复当前协程的上下文,但是并不是立即切换,
 //而是将切换的请求在调度器的IO_SERVICE里面排队,等待切换回上次运行的现场
 void sche_resume() {
     if(is_stoped() || is_dead()) {
         ORCHID_DEBUG("sche:%lu,coroutine:%lu,shce_resume in coroutine,stop:%s dead:%s",
             sche_id(),id(),is_stoped()?"true":"false",is_dead()?"true":"false");
         return;
     }
     // ORCHID_DEBUG("sche:%lu,coroutine:%lu,sche_resume",id(),sche_id());
     sche_.post(boost::bind(&scheduler_type::resume,&sche_,this->shared_from_this()));
 }
Example #2
0
 //恢复当前协程的上下文,立即切换
 void resume() {
     if(is_stoped() || is_dead()) {
         ORCHID_DEBUG("sche:%lu,coroutine:%lu,resume in coroutine,stop:%s dead:%s",
             sche_id(),id(),is_stoped()?"true":"false",is_dead()?"true":"false");
         return;
     }
     // ORCHID_DEBUG("sche:%lu,coroutine:%lu,resume",id(),sche_id());
     sche_.resume(this -> shared_from_this());
 }
Example #3
0
 //放弃运行,切换至调度器的上下文中
 //该函数只应该在当前协程的run函数中调用
 void yield() {
     ORCHID_DEBUG("sche:%lu,coroutine:%lu,yield",sche_id(),id());
     BOOST_ASSERT(!is_dead());
     boost::context::jump_fcontext(&ctx(),sche_.ctx(),0);
     if(is_stoped()) {
         //std::cout<<"throw here"<<std::endl;
         throw stack_unwind_exception();
     }
 }
Example #4
0
		void updater::check_if_need()
		{
            if (build::is_debug())
                return;

			if (!platform::is_windows())
				return;
            
			if ((std::chrono::system_clock::now() - last_check_time_) > std::chrono::hours(check_period))
			{
				update_params params;
				params.login_ = g_core->get_root_login();
				params.is_stoped_ = [this]() { return is_stoped(); };

				thread_->run_async_function([params]()->int32_t
				{
					return run(params);
				});

				last_check_time_ = std::chrono::system_clock::now();
			}
		}