There is a data race bug in the firstN and firstNSucc implementations. Make sure that the vector element is added BEFORE the promise is completed. Therefore, do not check if c == n but if the vector's size == n!
According to http://www.cplusplus.com/reference/vector/vector/size/ accessing the vector's size is thread-safe and does not lead to data races.
However, to be absolutely sure that the size has the correct value, we can still use the atomic size counter which is increased, after the element is added.
There is a data race bug in the firstN and firstNSucc implementations. Make sure that the vector element is added BEFORE the promise is completed. Therefore, do not check if c == n but if the vector's size == n!
According to http://www.cplusplus.com/reference/vector/vector/size/ accessing the vector's size is thread-safe and does not lead to data races. However, to be absolutely sure that the size has the correct value, we can still use the atomic size counter which is increased, after the element is added.