You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no way to interrupt a method like CircularBuffer.Read before the timeout limit is exceeded. This is problem is you want to gracefully wait for exit of a worker thread, you must wait the timeout of Read method. This applies to all methods that accept timeouts. To support cancellation for Read method, GetNodeForReading method should be modified like this
protectedunsafevirtualNode*GetNodeForReading(inttimeout,CancellationTokencancellationToken){Node*ptr;while(true){intreadStart=_nodeHeader->ReadStart;ptr=this[readStart];if(readStart==_nodeHeader->WriteEnd){intresult=WaitHandle.WaitAny(newWaitHandle[]{cancellationToken.WaitHandle,DataExists},timeout,false);if(result==WaitHandle.WaitTimeout||result==0){returnnull;}}elseif(Interlocked.CompareExchange(ref_nodeHeader->ReadStart,ptr->Next,readStart)==readStart){break;}}samegoes for other methods that are having wait handles.returnptr;}
The text was updated successfully, but these errors were encountered:
ekalchev
changed the title
Add cancellation to blocking methods
Add cancellation support for blocking methods
Nov 1, 2023
There is no way to interrupt a method like CircularBuffer.Read before the timeout limit is exceeded. This is problem is you want to gracefully wait for exit of a worker thread, you must wait the timeout of Read method. This applies to all methods that accept timeouts. To support cancellation for Read method, GetNodeForReading method should be modified like this
The text was updated successfully, but these errors were encountered: