UpdateableSpin Synchronization Primitive

Today we are going to look at a relatively rare case of synchronization. There are no appropriate C# synchronization primitives out of the box.
In order to understand the case we’re going to talk about you can imagine the following case: “Your code makes a call to the third-party library’s method and you have to wait that method until the end. That method performs a sequence of operations and at each step it will invoke a callback. In addition, by the agreement that method takes a timeout which is a max amount of time allocated for each step. After a callback is invoked, timeout will be reset. If you passed in 60 seconds as a timeout, then that third-party’s method will take 60 seconds for each step (if there are three steps, then 3*60 sec. is a maximum time amount may be spent on the overall execution).”

Continue reading