Ejemplo n.º 1
0
int main(int argc, char *argv[]) {

	auto system = actor_system::create_system("actor_system", 4444);

    auto props_local = bumbler::typed_props<local_actor, out_actor>();

    auto la1 = system->actor_of(props_local, "test_actor1");
    auto ra1 = actor_ref("test_actor1$actor_system@localhost:4444");

    std::future<std::string> f = la1.ask<std::string>(5);

    if(f.wait_for(std::chrono::seconds(1)) == std::future_status::ready) {
        INFO << "future result = " << f.get();
    }

    f = ra1.ask<std::string>(6);

    if(f.wait_for(std::chrono::seconds(1)) == std::future_status::ready) {
        INFO << "future result = " << f.get();
    }

    std::this_thread::sleep_for(std::chrono::seconds(1));

    system->stop(true);

    INFO << "EXIT";

    return 0;
}
Ejemplo n.º 2
0
//-------------------------------------------------------------------------------------------------
void TimerActor::do_setup (acto::actor_ref& sender, const TimerActor::msg_setup& msg) {
	event_t* const	p_event = new event_t( actor_ref() );
	// -
	p_event->actor = msg.actor;
	p_event->once  = msg.once;
	p_event->time  = msg.time;
	p_event->owner = self;
	// -
//	core::set_notify( 0, acto::dereference(actor), MakeDelegate(this, &timer_t::do_delete) );
	// Установить системный таймер
	if ( 0 != ::CreateTimerQueueTimer( &p_event->timer,
		                               // Очередь таймеров
									   m_timers,
									   // -
									   &TimerActor::TimerProc,
									   // Параметр для процедуры
									   p_event,
									   // Период первого вызова
									   msg.time,
									   // Повторы
									   (msg.once ? 0 : msg.time),
									   // Флаги
									   0 ) )
	{
		// -
		m_events.push_back( p_event );
	}
	else {
		// Ошибка. Таймер не был созда.
		delete p_event;
	}
}