3 ms·
> back-off Another solution is to simply return false and leave the decision of what to do, to the caller. Effectively: bool try_push(value_type& value);
by zamalek 12y ago
> back-off
Another solution is to simply return false and leave the decision of what to do, to the caller. Effectively:
bool try_push(value_type& value);
bool try_pop(value_type* result);
Most callers will simply:
while(!try_push(&val)) bkoff();
However, in my specific case I was writing a toy thread pool. This meant that a failed pend could just result in an attempt to pend it to a different worker thread, instead of trying the same stack over again.