Open hazzik opened 5 years ago
I do agree.
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 https://github.com/nhibernate/nhibernate-core/pull/2147#issue-275171711 :
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)
)