Home > Blockchain >  TMultiReadExclusiveWriteSynchronizer for android/ios
TMultiReadExclusiveWriteSynchronizer for android/ios

Time:09-26

On all platforms (except windows) TMultiReadExclusiveWriteSynchronizer is a TSimpleRWSync that internally simply use Tmonitor.enter / Tmonitor.exit and this is quite bad because only one read access at a time. Is their any equivalent of TMultiReadExclusiveWriteSynchronizer (windows version) that work on Android/iOS ?

CodePudding user response:

There is TLightweightMREW record in System.SyncObjs fully implemented on all platforms as thin wrapper around native OS implementations. Introduced in 10.4 Sydney.

There are some things to keep in mind:

  • Read access can be called recursively from same thread, but write access cannot - it will deadlock on Windows and raise exception on Posix platforms
  • Read access cannot be upgraded to write access.
  • Related