提升异步状态机

发布于 2024-10-19 11:39:48 字数 571 浏览 2 评论 0原文

是否可以从asynchronous_state_machine的processor_handle获取对调度程序的引用?

代码:

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); 

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); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆流 2024-10-26 11:39:48

不,目前还没有。根据设计,processor_handle 对象的存在并不能保证处理器所在的调度程序的存在。

因此,在您的场景中,您必须将调度程序传递给 A 的构造函数并将其存储在数据成员中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文