一个async_exec创建的任务,如何判定job结束
async_exec 创建了一个stack指令,并指定了执行次数 -n = 3,此时会另开线程去pull_result的结果,我如何通过pull_result返回的结果判定3次已经执行完成,然后终止pull_result? 看响应貌似区分不出该任务已终止
Your problem is:
You trigger async_exec to execute tasks multiple times (n=3). Then, you continuously call pull_result from another thread to retrieve task results. The problem is that the response from pull_result doesn't directly indicate whether all the tasks have completed or not. So you don't clearly know when to stop calling pull_result.
Common Approach (recommended): Since pull_result itself doesn't explicitly tell you "this is the last result," you'll need to keep track of the count of results you received, based on your known execution number (n=3):
Practical logic (simple):
Initialize a counter (completed_tasks = 0). Call pull_result repeatedly: Each successful response increments completed_tasks by 1. If completed_tasks == 3, you know all three tasks have completed, so you terminate the polling loop.