[PipeSleepStrategy] fix notifyFromAnywhere
Don't decrease the sleeper count in the CAS loop further than -count
, which is the threshold we need to ensure that the notification
will be observed.
Decreasing it further than our threshold is not faulty it just results in
unnecessary skipped sleeps.
Don't call writeNotifications
with a negative count.
Which will be interpreted as an unsigned value and thus results
in writing way to much hints to the pipe and jamming it.
If the original value before a successfully CAS is already negative
we called writeNotifications
with this negative value.
This is fixed by using the max(toWakeup, 0)
.
Edited by Florian Fischer