Asynchronous function call for C++

前端 未结 8 726
面向向阳花
面向向阳花 2021-02-09 17:38

I need a hint how to implement asynchronous function calls in C/C++ ( or names of frameworks/API calls for windows and/or linux )

The use case is following: A parent thr

相关标签:
8条回答
  • 2021-02-09 18:24

    Boost.Thread

    I believe this does the job well. Spin up the function call as a new thread and just don't bother joining it. It'll take care of that when it finishes anyway I believe.

    You could set it up so the child sends a signal to the parent when it finishes using Boost.Signals. This signal would be linked to the parent's callback function.

    0 讨论(0)
  • 2021-02-09 18:25

    You'll have to set up some kind of infrastructure to notify the caller that the work is done. This could be done with an Observer pattern type. A message type infrastructure can be used as well.

    The real question is what is your parent going to do while it waits. Do you want it to poll for results? Or get notified?

    0 讨论(0)
提交回复
热议问题