Commit Graph

17 Commits

Author SHA1 Message Date
Jonas Maebe
b1a2b405ea * TMultiReadExclusiveWriteSynchronizer: removed some unnecessary barriers and
added some potentially missing ones

git-svn-id: trunk@41166 -
2019-02-02 15:19:32 +00:00
Jonas Maebe
265923a2ee * several fixes for TMultiReadExclusiveWriteSynchronizer, based on patch by
Derek (mantis #28830)
   o ability for a thread to acquire a readlock when it already holds a
     write lock, or vice versa
   o detect when thread1 releases a lock while it hadn't acquired one
   o correct result of beginwrite (return true only when another thread
     held/acquired a write lock before the current thread got it)
   o extra compared to Derek's patch: replaced some additional
     (mostly pre-existing) interlocked*() hacks with proper memory
     barriers, made formatting consistent, fixed compilation on platforms
     where tthreadid is not an integer type, improved tthreadid hashing
     function for 64 bit platforms, fixed some comments

git-svn-id: trunk@34678 -
2016-10-08 20:45:45 +00:00
Jonas Maebe
35c64a7a69 * properly order all operations in TMultiReadExclusiveWriteSynchronizer
using memory barriers, rather than half-heartedly using atomic
    operations. Fixes random failures in trwsync on POWER7 processors
    (and probably other weakly ordered architectures)

git-svn-id: trunk@27723 -
2014-05-03 14:19:54 +00:00
florian
82f20cedbd * make threading code dependend on feature switch
git-svn-id: trunk@23293 -
2013-01-02 10:48:29 +00:00
Jonas Maebe
d5f415b047 * initialise fwritelocked and freadercount in the TMREWS constructor using
atomic operations so that in case it's created while multiple threads are
    already running, all threads are guaranteed to see this initialisation
  * some minor changes to the comments of TMREWS

git-svn-id: trunk@15074 -
2010-03-27 12:44:51 +00:00
Jonas Maebe
89e4e0fd25 * only wake up readers if all recursive write locks have been freed
git-svn-id: trunk@14831 -
2010-01-29 21:56:46 +00:00
Jonas Maebe
13e8b3f23e * don't give a "NoThreadError" for any default rtl/basicevent* routines,
so the TMultiReadExclusiveWriteSynchronizer routines can be safely
    executed even with the default thread manager -> removed ismultithread
    checks, so that it keeps working even if ismultithread is set to true
    between acquiring and freeing a lock (mantis #15619)

git-svn-id: trunk@14830 -
2010-01-29 21:01:11 +00:00
Jonas Maebe
e4858445c7 * make sure fwritelocked remains set correctly when using recursive write locks
git-svn-id: trunk@14828 -
2010-01-29 18:10:10 +00:00
Jonas Maebe
2c477269d0 * added a readbarrier after acquiring a read or write lock on
TMultiReadExclusiveWriteSynchronizer, to ensure that out-of-order
    execution cannot already perform some reads inside the critical section
    before the lock has been acquired
  - removed now unnecessary read barrier before releasing a read lock

git-svn-id: trunk@14820 -
2010-01-27 22:23:41 +00:00
Jonas Maebe
49f01e7b64 * replaced writelock of TMultiReadExclusiveWriteSynchronizer with a
critical section, so that it can be entered recursively just like
    the one from TSimpleRWSync + test
  - reverted r14593, since the reason for using TRWSync instead of
    TMultiReadExclusiveWriteSynchronizer was because the former
    supported recursive write locks

git-svn-id: trunk@14594 -
2010-01-10 12:14:21 +00:00
Jonas Maebe
356845ba1e * set function results for unimplemented generic thread manager routines
(to remove warnings)
  * don't give a thread error for basicevent and threadevent routines if
    isMultiThreaded is false, except for the waiting routines (the new
    TMultiReadExclusiveWriteSynchronizer creates/sets such events in the
    constructor, which caused thread manager errors in case cthreads was
    not used under unix)
  * don't perform any actual locking in TMultiReadExclusiveWriteSynchronizer
    routines if isMultiThreaded is false (in order to avoid the errors
    described above)
  + added generic RTLeventResetEvent stub

git-svn-id: trunk@14592 -
2010-01-10 11:04:05 +00:00
paul
9bad162368 rtl: fix crash in TMultiReadExclusiveWriteSynchronizer.Beginwrite
git-svn-id: trunk@14591 -
2010-01-10 09:35:37 +00:00
paul
538cf8667b rtl: fix compilation under windows
git-svn-id: trunk@14590 -
2010-01-10 06:28:50 +00:00
Jonas Maebe
8da0a031bf * fixed memory leak in new TMultiReadExclusiveWriteSynchronizer
(fwaitingwriterlock was not freed)
  * fixed typo in comment
  * free all memory in trwsync.pp test

git-svn-id: trunk@14588 -
2010-01-09 23:14:53 +00:00
Jonas Maebe
106baa8b2f * optimized version of TMultiReadExclusiveWriteSynchronizer that allows
concurrent readers (mantis #14451)

git-svn-id: trunk@14587 -
2010-01-09 23:00:45 +00:00
florian
d629426b67 + system qualifier added
git-svn-id: trunk@1187 -
2005-09-25 14:35:01 +00:00
florian
c7cd9ff06b * TMultiReadExclusiveWriteSynchronizer fixed and moved to SysUtils
git-svn-id: trunk@1164 -
2005-09-23 13:07:11 +00:00