Przemyslaw Czerpak-2 wrote: > > In this code we have: > lInUse := ! lInUse > To make this code MT safe the above line has to be one atomic > operation in xBase++. Is it true? >
This is not true in Xbase++. Each variable access (read and write) is serialized independently which guarantees valid value access and assignment. Xbase++ at the .PRG level ONLY provides thread synchronization through SYNC methods of class objects for building atomic operations larger than access/assign. SYNC methods acquire a mutex lock embedded in the class instance prior to method entry and release the lock upon method exit. It is expected (and required) that thread shared values which must be synchronized be directly or indirectly controlled by the oject instance. Nested SYNC methods are supported with the mutex held through the entire sequence. All SYNC methods of an object instance shared the same mutex. Przemyslaw Czerpak-2 wrote: > > The key is in: > lInUse := ! lInUse > line. This code can be MT safe _only_ if xBase++ executes this > whole line as one atomic operation. > So far I haven't found any information about such functionality. > Per the above, you won't find that information because your operation is only thread safe when inside a SYNC method and lInUse is an instance variable. Rodd Graham -- View this message in context: http://www.nabble.com/A-few-questions-about-MT-tp19555409p19683494.html Sent from the Harbour - Dev mailing list archive at Nabble.com. _______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour