justinstenning / SharedMemory

C# shared memory classes for sharing data between processes (Array, Buffer and Circular Buffer)
https://www.nuget.org/packages/SharedMemory
Other
566 stars 118 forks source link

Feature/add cancellation #64

Closed shuebner closed 2 years ago

shuebner commented 2 years ago

Adds cancellation via Cancellation token.

Cancellation via cancellation token is unified with the existing cancellation via timeout by using some code from Stephen Cleary's AsyncEx. IMHO it improved and simplified the timeout code.

It seems to not break anything according to the tests, has no breaking API changes.

It also seems to not have a significant impact on performance one way or the other: image

If there are no major complaints, I will try to add some unit tests soon for the functionality.

justinstenning commented 2 years ago

Thanks @shuebner looks fine, please go ahead and add some unit tests.

shuebner commented 2 years ago

I rebased onto the latest changes. Note that my first commit just makes the existing code compile, see commit message.

I added two unit tests each for the synchronous and asynchronous SendMessage method call with a cancellation token: one with actual cancellation, one without cancellation.

shuebner commented 2 years ago

@spazzarama When will you have time to review the changes?

justinstenning commented 2 years ago

Will try to get this on the weekend

shuebner commented 2 years ago

@spazzarama several weekends later... ;-)