#1 2021-02-12 16:02:36

keinn
Member
Registered: 2014-10-20
Posts: 103

functional suggestion :a MultiReadExclusiveWrite lock is need

may be ,we need a MultiReadExclusiveWrite / MultiReadSingleWrite kind of lock in mormot code base.
like Delphi 10.4 TLightweightMREW wrapper or TSpinLock.
or like this repo:https://github.com/BeRo1985/pasmp

Offline

#2 2021-02-12 17:08:44

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: functional suggestion :a MultiReadExclusiveWrite lock is need

Yes, I have seen it and will add something similar to mORMot 2.

smile

Offline

#3 2021-02-16 14:09:08

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: functional suggestion :a MultiReadExclusiveWrite lock is need

For Linux we already have a pthread_rwlock_wrlock, for windows - SRW locks.

From my experiments there is no real performance benefits from using both of them compared to critical section (mutex) in the real life scenarios (for example for session list in mORMot). For some SPECIFIC use cases it makes sense, for sure, but I can't see where to use it in mORMot.

But using such structures adds additional complexity, because both can't be used inside recursion calls. So personally  I vote for simplicity (mutex)

Offline

#4 2021-02-17 08:30:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: functional suggestion :a MultiReadExclusiveWrite lock is need

It could make sense for TSynDictionary for instance.

And making those OS structures re-entrant is not difficult: we just have to maintain a ThreadID of the writelocker, and keep a counter.

Offline

Board footer

Powered by FluxBB