boost asynchronous_state_machine
Is it possible to get ref to scheduler from processor_handle for asynchronous_state开发者_运维技巧_machine?
Code:
struct A {
A(sc::fifo_scheduler<>::processor_handle& h):player_ref(h){}
sc::fifo_scheduler<>::processor_handle& player_ref;
void a_func(){
//I have to send event to player, but don't have scheduler
scheduler.queue_event( player_ref_, ... ); //?
}
};
sc::fifo_scheduler<> scheduler( true );
sc::fifo_scheduler<>::processor_handle player =
scheduler1.create_processor< Player >();
A a(player);
No, not currently. By design, the existence of a processor_handle object does not guarantee the existence of the scheduler the processor is hosted in.
So, in your scenario you have to pass the scheduler to the constructor of A and store it in a data member.
精彩评论