2

Regarding the AWS c++ sdk thread pool feature, is there an elegant way to wait for PooledThreadExecutor to finish all tasks in the queue after calling -for example- getObjectAsync many times ?

Or should I just use getObjectCallable, store references to all future objects in an array, loop the array and wait for each one.

demon36
  • 377
  • 3
  • 10

1 Answers1

2

The destructor of the PooledThreadExecutor will join its threads. Effectively as if you would have used the Callable version and waited till the request returned before exiting.

Marco M.
  • 2,956
  • 2
  • 29
  • 22
  • but looking into the code at Executor.cpp and ThreadTask.cpp it appears that the executor just waits for finishing tasks currently being processed, but worker threads don't take any more tasks from the queue once m_continue is set to false. – demon36 Jan 05 '18 at 12:52
  • 1
    Oh I see what you mean. Unfortunately, there’s no “flush” operation. You should call the Callable version instead. Or use your own synchronization primitives. – Marco M. Jan 06 '18 at 15:13