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

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Jul 31 11:17:58 CEST 2008


On Thu, 31 Jul 2008 11:02:28 +0200
Florian Klaempfl <florian at freepascal.org> wrote:

> 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.

Do you mean one global crit sect per class (and descendants) or one
global crit sect for all classes?

 
> 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.

Will this also allowed for methods?

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

I like it.

Mattias



More information about the fpc-devel mailing list