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
Currently, the async generator is generating separate fields for lock statements that contain an async invocation, which may cause troubles as two threads may simultaneously execute the same code, one for async and one in sync version of the method.
I think the rules should be like following:
If there are several methods with [MethodImpl(Synchronized)] in a class the generator shall generate only one locker fields for all these methods.
(Optional) The locker should pass the current lock object to the async lock. (MethodImplOptions.Synchronized is actually equivalent to lock(GetType())/lock(this))
The text was updated successfully, but these errors were encountered:
The problem with async locking is that all implementations that I am aware of do not support to pass a lock object which would be used to lock a thread. By not having such async locking, it is not possible to achieve blocking different threads from executing the same code, which can lead to various bugs that are hard to debug. Allowing such behavior doesn't seem right to me and that is why my plan was to remove support for MethodImpl attribute and lock statement. Leaving this as optional, maybe, but I don't think this should be set by default.
@maca88 nhibernate/nhibernate-core#2147 (comment) :
I think the rules should be like following:
If there are several methods with
[MethodImpl(Synchronized)]
in a class the generator shall generate only one locker fields for all these methods.(Optional) The locker should pass the current lock object to the async lock. (
MethodImplOptions.Synchronized
is actually equivalent tolock(GetType())
/lock(this)
)The text was updated successfully, but these errors were encountered: