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

Florian Klaempfl florian at freepascal.org
Thu Jul 31 11:02:28 CEST 2008


Before we discuss endless about useless stuff, I'll make a proposal for 
a first addition: support of the synchronized keyword. It does no more 
than protecting a procedure automatically by a critical section so only 
one thread can enter it. But I want to extend it. First, it can be 
applied also to classes and object:

tmyclass = class(...) synchronized

This means that all classes synchronize against one critical section.

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 :)



More information about the fpc-devel mailing list