fpc/tests/test/tclass16.pp
svenbarth c3ca96279a + add support for threadvars inside classes
+ added tests

git-svn-id: trunk@39288 -
2018-06-23 13:49:12 +00:00

39 lines
516 B
ObjectPascal

{ %SKIPTARGET=$nothread }
program tclass16;
{$mode objfpc}
{$ifdef unix}
uses
cthreads;
{$endif}
type
TTest = class
public class threadvar
Test: LongInt;
end;
function TestFunc(aData: Pointer): PtrInt;
var
e: PRTLEvent;
begin
e := PRTLEvent(aData);
TTest.Test := 42;
RTLeventSetEvent(e);
Result := 0;
end;
var
e: PRTLEvent;
begin
TTest.Test := 21;
e := RTLEventCreate;
BeginThread(@TestFunc, e);
RTLeventWaitFor(e);
if TTest.Test <> 21 then
Halt(1);
Writeln('Ok');
end.