-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathJoinN.dpr
More file actions
38 lines (31 loc) · 817 Bytes
/
JoinN.dpr
File metadata and controls
38 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
program JoinN;
{$APPTYPE CONSOLE}
{$R *.res}
uses
{$I ../Impl.inc}
{$I ../Includes.inc}
System.SysUtils;
var
Routine: TSymmetricRoutine<Integer, Boolean>;
begin
Routine := procedure(const Counter: Integer; const RaiseAbort: Boolean)
var
I: Integer;
begin
for I := 1 to Counter do
Yield;
if RaiseAbort then
Abort;
end;
try
// exception raised in greenlets will be reraised to caller context
Join([
TSymmetric<Integer, Boolean>.Spawn(Routine, 100, False),
TSymmetric<Integer, Boolean>.Spawn(Routine, 1000, False),
TSymmetric<Integer, Boolean>.Spawn(Routine, 10000, True)
], INFINITE, True)
except on E: Exception do
WriteLn(Format('Exception %s was raised', [E.ClassName]))
end;
ReadLn;
end.