File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,15 @@ if (isDelegate!Dg)
8383 }
8484 }
8585
86+ /**
87+ * Cancel the call. If the callback is already canceled or executed, this
88+ * method has no effect.
89+ */
8690 override void cancel ()
8791 {
8892 this .cancelled = true ;
93+ this .dg = null ;
94+ this .args = Args.init;
8995 }
9096
9197 protected override void opCallImpl ()
Original file line number Diff line number Diff line change @@ -17,6 +17,42 @@ unittest
1717 assert (fooCalled);
1818}
1919
20+ unittest
21+ {
22+ auto loop = getEventLoop;
23+ int bar = 0 ;
24+
25+ void foo (int i)
26+ {
27+ bar = i;
28+ loop.stop;
29+ }
30+
31+ loop.callSoon(&foo, 10 );
32+ assert (bar == 0 );
33+ loop.runForever;
34+ assert (bar == 10 );
35+ }
36+
37+ unittest
38+ {
39+ auto loop = getEventLoop;
40+ int bar = 0 ;
41+
42+ void foo (int i)
43+ {
44+ bar += i;
45+ loop.stop;
46+ }
47+
48+ auto h1 = loop.callSoon(&foo, 10 );
49+ auto h2 = loop.callSoon(&foo, 15 );
50+ assert (bar == 0 );
51+ h1.cancel;
52+ loop.runForever;
53+ assert (bar == 15 );
54+ }
55+
2056unittest
2157{
2258 import std.datetime : msecs;
You can’t perform that action at this time.
0 commit comments