Subject | thread var in UDF lib |
---|---|
Author | Moravecz László (eMeL) |
Post date | 2004-02-14T13:02:18Z |
I have catched out above example code from Borland.
The 'threadvar' is enought for this restriction?
"You must design UDFs for SuperServer as thread-safe functions. You cannot use
global variables in your UDF library..." (from
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_ss_vs_classic)
eMeL
------------------------------------
ISC_QUAD = record
isc_quad_high : Integer ; // Date
isc_quad_low : Cardinal ; // Time
end;
threadvar
tempquad : ISC_QUAD;
Then, write your function so that the result points to the threaded
variable.
// This function adds a number of days to an existing date.
function DayAdd( var Days: Integer; IBDate PISC_QUAD) : PISC_QUAD; cdecl;
export;
begin
tempquad.isc_quad_high := IBDate^.isc_quad_high + Days;
tempquad.isc_quad_low := IBDate^.isc_quad_low;
Result := @tempquad;
end;
The 'threadvar' is enought for this restriction?
"You must design UDFs for SuperServer as thread-safe functions. You cannot use
global variables in your UDF library..." (from
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_ss_vs_classic)
eMeL
------------------------------------
ISC_QUAD = record
isc_quad_high : Integer ; // Date
isc_quad_low : Cardinal ; // Time
end;
threadvar
tempquad : ISC_QUAD;
Then, write your function so that the result points to the threaded
variable.
// This function adds a number of days to an existing date.
function DayAdd( var Days: Integer; IBDate PISC_QUAD) : PISC_QUAD; cdecl;
export;
begin
tempquad.isc_quad_high := IBDate^.isc_quad_high + Days;
tempquad.isc_quad_low := IBDate^.isc_quad_low;
Result := @tempquad;
end;