是否可以从processor_handle获取对asynchronous_state_machine的调度程序的引用?
码:
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);
最佳答案
不,目前不行。通过设计,processor_handle对象的存在并不能保证处理器所在的调度程序的存在。
因此,在您的方案中,您必须将调度程序传递给A的构造函数,并将其存储在数据成员中。