Subject | Re: [firebird-support] how to implement thread safe UDFs ? |
---|---|
Author | Martijn Tonies |
Post date | 2004-03-17T17:02:33Z |
Hi Kamlesh,
use thread-safe functions in your own function, it will be
thread-safe already. Or at least, according to me ;-)
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> what can be said the better way to implement thread safe UDFs ?If you don't use any global variables or global objects and
> can i make my functions thread safe by using CriticalSection in following
> manner ?
>
> // following is my UDF Library Unit
>
> unit MyUDFUnit;
>
> interface
> uses
> SysUtils, SyncObjs;
>
> Var
> FCriticalsection: TCriticalSection;
>
> implementation
>
> Procedure EnterFunction;
> Begin
> FCriticalsection.Enter;
> End;
>
> Procedure ExitFunction;
> Begin
> FCriticalsection.Leave;
> End;
>
> Function MyFunction(ACString:PChar):Integer; cdecl; export;
> Begin
> EnterFunction;
>
> // do some work here
use thread-safe functions in your own function, it will be
thread-safe already. Or at least, according to me ;-)
> ExitFunction;With regards,
> End;
>
> exports
> MyFunction;
>
> Initialization
> FCriticalsection := TCriticalSection.Create;
> Finalization
> FCriticalsection.Free;
> End.
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com