fpc/tests/tbs/tb0678.pp
svenbarth 432fcd52bc Merged revision(s) 45409, 46897-46898, 47007, 47011, 47065, 47084 from trunk:
* fix for Mantis #37042: apply patch and test (adjusted for Big Endian) by Bi0T1N to add support for TBitConverter
........
* avoid range check error when using SwapEndian with 16-bit constants
+ added test
........
* readd SmallInt typecasts to SmallInt overload of SwapEndian
........
* when removing a method from the synchronization queue using TThread.RemoveQueuedEvent then both the Code and the Data need to match (Delphi does the same)
+ added test
........
* simplify TThread.RemoveQueuedEvent - decide what to delete and not what to leave (better corresponds with the docs)
........
+ add ability to specify a SQLite VFS when opening a SQLite database
........
* fix test: TThread.WaitFor calls CheckSynchronize as well, so the thread needs to signal when it's done with removing entries from the queue
........

git-svn-id: branches/fixes_3_2@47782 -
2020-12-15 22:31:59 +00:00

81 lines
1.0 KiB
ObjectPascal

{%skiptarget=$nothread }
program tqueue;
{$mode objfpc}
uses
{$ifdef unix}
cthreads,
{$endif}
SysUtils, Classes;
type
TTest = class
procedure DoTest;
end;
TTestThread = class(TThread)
protected
procedure Execute; override;
end;
var
count: LongInt = 0;
procedure TTest.DoTest;
begin
Inc(count);
end;
var
e: PRTLEvent;
t1, t2: TTest;
procedure TTestThread.Execute;
var
method: TMethod;
begin
Queue(@t1.DoTest);
Queue(@t2.DoTest);
{ should remove nothing }
method.Code := @TTest.DoTest;
method.Data := Nil;
RemoveQueuedEvents(TThreadMethod(method));
{ should remove only one }
RemoveQueuedEvents(@t1.DoTest);
RTLEventSetEvent(e);
end;
var
t: TTestThread;
begin
e := Nil;
t := TTestThread.Create(True);
try
e := RTLEventCreate;
t1 := TTest.Create;
t2 := TTest.Create;
t.Start;
RTLEventWaitFor(e);
t.WaitFor;
CheckSynchronize;
if count <> 1 then
Halt(1);
finally
t1.Free;
t2.Free;
t.Free;
RTLEventDestroy(e);
end;
end.