Skip to content

Commit 6cf45a6

Browse files
Added WaitFor method on token interface.
1 parent 507f791 commit 6cf45a6

File tree

4 files changed

+675
-136
lines changed

4 files changed

+675
-136
lines changed

Source/VSoft.CancellationToken.Impl.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ TCancellationToken = class(TCancellationTokenBase, ICancellationToken, ICancel
4646
function GetEvent : TEvent;virtual;
4747
{$ENDIF}
4848
function IsCancelled: boolean;virtual;
49+
function WaitFor(Timeout: Cardinal): TWaitResult;virtual;
4950
procedure Cancel;virtual;
5051
procedure Reset;virtual;
5152
public
@@ -102,4 +103,9 @@ procedure TCancellationToken.Reset;
102103
end;
103104

104105

106+
function TCancellationToken.WaitFor(Timeout: Cardinal): TWaitResult;
107+
begin
108+
result := FEvent.WaitFor(Timeout);
109+
end;
110+
105111
end.

Source/VSoft.CancellationToken.pas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ interface
3333
System.SyncObjs;
3434

3535
type
36+
//TDODO : use system.types if available.
37+
TWaitResult = System.SyncObjs.TWaitResult;
38+
3639
/// ICancellationToken is passed to async methods
3740
/// so that they can determin if the caller has
3841
/// cancelled.
@@ -44,7 +47,7 @@ interface
4447
function GetEvent : TEvent;
4548
{$ENDIF}
4649
function IsCancelled: boolean;
47-
50+
function WaitFor(Timeout: Cardinal): TWaitResult;
4851
{$IFDEF MSWINDOWS}
4952
//Note : do not call SetEvent on this handle
5053
//as it will result in IsSignalled prop

0 commit comments

Comments
 (0)