tbrtlevt.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {$mode objfpc}
  2. uses
  3. {$ifdef unix}
  4. cthreads,
  5. {$endif}
  6. sysutils,
  7. classes;
  8. type
  9. tc = class(tthread)
  10. procedure execute; override;
  11. end;
  12. var
  13. event: pEventState;
  14. waiting: boolean;
  15. procedure tc.execute;
  16. begin
  17. { make sure we don't exit before this thread has initialised, since }
  18. { it can allocate memory in its initialisation, which would cause }
  19. { problems for heaptrc as it goes over the memory map in its exit code }
  20. waiting:=true;
  21. { avoid deadlocks/bugs from causing this test to never quit }
  22. sleep(1000*20);
  23. halt(1);
  24. end;
  25. begin
  26. waiting:=false;
  27. tc.create(false);
  28. event := BasicEventCreate(nil,false,false,'bla');;
  29. basiceventSetEvent(event);
  30. if (basiceventWaitFor(cardinal(-1),event) <> 0) then
  31. begin
  32. writeln('error');
  33. halt(1);
  34. end;
  35. { shouldn't change anything }
  36. basiceventResetEvent(event);
  37. basiceventSetEvent(event);
  38. { shouldn't change anything }
  39. basiceventSetEvent(event);
  40. if (basiceventWaitFor(cardinal(-1),event) <> 0) then
  41. begin
  42. writeln('error');
  43. halt(1);
  44. end;
  45. basiceventdestroy(event);
  46. while not waiting do
  47. sleep(20);
  48. end.