Skip to content

Commit 1a15618

Browse files
committedJun 29, 2020
[threads] some changes
1 parent 41ee42b commit 1a15618

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
 

‎Quick.Threads.pas

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{ ***************************************************************************
22
3-
Copyright (c) 2016-2019 Kike Pérez
3+
Copyright (c) 2016-2020 Kike Pérez
44
55
Unit : Quick.Threads
66
Description : Thread safe collections
77
Author : Kike Pérez
88
Version : 1.5
99
Created : 09/03/2018
10-
Modified : 02/12/2019
10+
Modified : 27/06/2020
1111
1212
This file is part of QuickLib: https://github.com/exilon/QuickLib
1313
@@ -265,8 +265,10 @@ ETaskSchedulerError = class(Exception);
265265
IWorkTask = interface(ITask)
266266
function OnInitialize(aTaskProc : TTaskProc) : IWorkTask;
267267
function OnException(aTaskProc : TTaskExceptionProc) : IWorkTask;
268+
function OnException_Sync(aTaskProc : TTaskExceptionProc) : IWorkTask;
268269
function OnRetry(aTaskProc : TTaskRetryProc) : IWorkTask;
269270
function OnTerminated(aTaskProc : TTaskProc) : IWorkTask;
271+
function OnTerminated_Sync(aTaskProc : TTaskProc) : IWorkTask;
270272
function Retry(aMaxRetries : Integer) : IWorkTask;
271273
function RetryForever : IWorkTask;
272274
function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer) : IWorkTask; overload;
@@ -385,7 +387,9 @@ TWorkTask = class(TTask,IWorkTask)
385387
public
386388
function OnInitialize(aTaskProc : TTaskProc) : IWorkTask;
387389
function OnException(aTaskProc : TTaskExceptionProc) : IWorkTask; virtual;
390+
function OnException_Sync(aTaskProc : TTaskExceptionProc) : IWorkTask; virtual;
388391
function OnTerminated(aTaskProc : TTaskProc) : IWorkTask; virtual;
392+
function OnTerminated_Sync(aTaskProc : TTaskProc) : IWorkTask; virtual;
389393
function OnRetry(aTaskProc : TTaskRetryProc) : IWorkTask; virtual;
390394
function Retry(aMaxRetries : Integer) : IWorkTask;
391395
function RetryForever : IWorkTask;
@@ -1346,6 +1350,12 @@ function TWorkTask.OnException(aTaskProc : TTaskExceptionProc) : IWorkTask;
13461350
Result := Self;
13471351
end;
13481352

1353+
function TWorkTask.OnException_Sync(aTaskProc: TTaskExceptionProc): IWorkTask;
1354+
begin
1355+
fExceptionWithSync := True;
1356+
Result := OnException(aTaskProc);
1357+
end;
1358+
13491359
function TWorkTask.OnInitialize(aTaskProc: TTaskProc): IWorkTask;
13501360
begin
13511361
fInitializeProc := aTaskProc;
@@ -1364,6 +1374,12 @@ function TWorkTask.OnTerminated(aTaskProc: TTaskProc): IWorkTask;
13641374
Result := Self;
13651375
end;
13661376

1377+
function TWorkTask.OnTerminated_Sync(aTaskProc: TTaskProc): IWorkTask;
1378+
begin
1379+
fTerminateWithSync := True;
1380+
Result := OnTerminated(aTaskProc);
1381+
end;
1382+
13671383
procedure TWorkTask.Run;
13681384
begin
13691385
fEnabled := True;

0 commit comments

Comments
 (0)
Failed to load comments.