Multi threading support was Re: [fpc-devel] Russian locale information not compatible withFPClocale variables

Marco van de Voort marcov at stack.nl
Thu Jul 31 20:05:50 CEST 2008


> one thread can enter it. But I want to extend it. First, it can be 
> applied also to classes and object:
> 
> tmyclass = class(...) synchronized

A  class protected by a sync object is a monitor. Several other languages
have this as a first class citizen.

 TMyClass = Monitor (xxx)

> This means that all classes synchronize against one critical section.

For the straight case this is ok, but what about virtual methods ? 
 
> Further, it allows an additional symbol to be given
> 
> procedure p;synchronized mycriticialsection;
> 
> it must be of the type System.TRTLCriticalSection and the procedure will 
> be synchronized against this critical section.
> 
> Besides saving the typing of endless try ... finally statements and the 
> initialiation of the unnamed critical sections, it creates also slightly 
> better code because the LeaveCriticalSection call can be inside the 
> implicit exception frame which is created anyways.

> Any suggestions about doing it better?
> 
> BTW: I'll ignore comments like "nobody needs this", I need it :)

For methods or classes? I think single classes with an own syncobj are the
rare case?



More information about the fpc-devel mailing list