-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSymmetric.dpr
More file actions
47 lines (40 loc) · 864 Bytes
/
Symmetric.dpr
File metadata and controls
47 lines (40 loc) · 864 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
39
40
41
42
43
44
45
46
47
program Symmetric;
{$APPTYPE CONSOLE}
{$R *.res}
uses
{$I ../Impl.inc}
{$I ../Includes.inc}
System.SysUtils;
var
S: TSymmetric<Integer>;
Proc: TSymmetricRoutine<Integer>;
begin
Proc := procedure(const Input: Integer)
var
Internal: Integer;
begin
WriteLn('Input value: ', Input);
try
Internal := Input;
while True do
begin
Yield; // return to caller context
Inc(Internal);
WriteLn('Internal = ', Internal);
end
finally
WriteLn('Execution is terminated...')
end
end;
S := TSymmetric<Integer>.Create(Proc, 10);
// Manually call to Switch is not thread safe so this call is not declared
// in Symmetric interface
with IRawGreenlet(S) do
begin
Switch;
Switch;
Switch;
end;
S.Kill;
Readln;
end.