Asynchronous function call for C++

2019-03-16 07:29发布

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 thread calls a function. The function creates a child thread and returning, so call is non-blocking and parent thread can continue to do some job.

For example pthread_join to get result is not suitable, so result must be stored somewhare in heap and parent must be notified about. What I want is something like callback function in parent thread, that would be executed after child thread is ready with job.

This is surprising, but I can not find a single example in google.

Thanks for help

8条回答
女痞
2楼-- · 2019-03-16 08:02

Use Qt framework and Thread classes or the Qt Concurrency framework.

Connect to QThread::finished() or QFutureWatcher::finished() signal to be notified when the work is done.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-16 08:16

Use boost::thread as the standard cross-platform solution. If you need something more involved, there's Intel's Thread Building Blocks.

查看更多
登录 后发表回答