Closed poor1017 closed 1 year ago
Ah, the assumption was that one of the tasks would cause the processing code to break out of the loop. I could probably make that more clear (at the expense of a longer example).
If using wait_dequeue()
and the queue may be empty all the time, the loop may hang all the time, at this time, how to break out of the loop?
And now, if some one destroy the queue, an undefined error occurs?
It's the responsibility of whoever owns the thread (and queue) to tell it to clean itself up. There's multiple ways to do this, but a common one is to set a flag and enqueue dummy data to wake up the thread, then join it.
Got it, thank you!
Hi @cameron314
I read all the samples in
concurrentqueue/samples.md
, they are great, except:For sample: Threadpool task queue I think we should replace
wait_dequeue()
withwait_dequeue_timed()
. Because there is awhile (true)
, so we need a break to exit thiswhile
, butwait_dequeue()
may cause the break never be achieved.Thank you!