2017-01-27 17:37:51 +02:00
|
|
|
unit uCEFWaitableEvent;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 21:56:46 +02:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 19:56:41 +02:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
type
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefWaitableEventRef = class(TCefBaseRefCountedRef, ICefWaitableEvent)
|
2017-01-27 17:37:51 +02:00
|
|
|
protected
|
|
|
|
procedure Reset;
|
|
|
|
procedure Signal;
|
|
|
|
function IsSignaled : boolean;
|
|
|
|
procedure Wait;
|
|
|
|
function TimedWait(max_ms: int64): boolean;
|
|
|
|
|
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefWaitableEvent;
|
2018-08-01 10:00:23 +02:00
|
|
|
class function New(automatic_reset, initially_signaled : boolean): ICefWaitableEvent;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions;
|
|
|
|
|
|
|
|
procedure TCefWaitableEventRef.Reset;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefWaitableEvent(FData)^.reset(PCefWaitableEvent(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefWaitableEventRef.Signal;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefWaitableEvent(FData)^.signal(PCefWaitableEvent(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefWaitableEventRef.IsSignaled : boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := (PCefWaitableEvent(FData)^.is_signaled(PCefWaitableEvent(FData)) <> 0);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefWaitableEventRef.Wait;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefWaitableEvent(FData)^.wait(PCefWaitableEvent(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefWaitableEventRef.TimedWait(max_ms: int64): boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := (PCefWaitableEvent(FData)^.timed_wait(PCefWaitableEvent(FData), max_ms) <> 0);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefWaitableEventRef.UnWrap(data: Pointer): ICefWaitableEvent;
|
|
|
|
begin
|
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefWaitableEvent
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
2018-08-01 10:00:23 +02:00
|
|
|
class function TCefWaitableEventRef.New(automatic_reset, initially_signaled : boolean): ICefWaitableEvent;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-08-01 10:00:23 +02:00
|
|
|
Result := UnWrap(cef_waitable_event_create(Ord(automatic_reset), Ord(initially_signaled)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|