Commit e44d5e85 authored by Xavier Thompson's avatar Xavier Thompson

join.hpp: Apply no-theft optimisation in final_suspend

parent 607b3753
...@@ -122,6 +122,10 @@ namespace typon ...@@ -122,6 +122,10 @@ namespace typon
{ {
Continuation::Data & data = coroutine.promise()._data; Continuation::Data & data = coroutine.promise()._data;
u64 thefts = data._thefts; u64 thefts = data._thefts;
if (thefts == 0)
{
return data._continuation;
}
u64 n = data._n.fetch_sub(UMAX - thefts, std::memory_order_acq_rel); u64 n = data._n.fetch_sub(UMAX - thefts, std::memory_order_acq_rel);
if (n - (UMAX - thefts) == 0) if (n - (UMAX - thefts) == 0)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment