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
Let's use JetBrains.Dataflow.Lifetime here to prevent the following case:
Thread 1 performs Volatile.Read (and reads the "good" client)
Thread 2 performs Volatile.Write(None)
Thread 1 starts to perform some calls on the client
Thread 2 at the same time calls client.Dispose()
As the result, client could become disposed in parallel with some calls by thread 1, which is very bad (at least theoretically). It is in my opinion worse than any calls on a non-disposed client (even if it has already failed).
Here we should use the lifetime pattern and lifetime.Using, and instead of Volatile.Read we better call lifetime.ExecuteIfAlive that should prevent us from disposing a lifetime that has some ongoing calls on it.
Let's use
JetBrains.Dataflow.Lifetime
here to prevent the following case:Volatile.Read
(and reads the "good" client)Volatile.Write(None)
client
client.Dispose()
As the result,
client
could become disposed in parallel with some calls by thread 1, which is very bad (at least theoretically). It is in my opinion worse than any calls on a non-disposed client (even if it has already failed).Here we should use the
lifetime
pattern andlifetime.Using
, and instead ofVolatile.Read
we better calllifetime.ExecuteIfAlive
that should prevent us from disposing a lifetime that has some ongoing calls on it.Originally posted as a comment to #59
The text was updated successfully, but these errors were encountered: