schedulerObject

schedulerObject
(
TScheduler
)
(
auto ref TScheduler scheduler
)

Examples

1 struct MyScheduler
2 {
3     void start(void delegate() op)
4     {
5     }
6 }
7 
8 class MyClassScheduler
9 {
10     void start(void delegate() op)
11     {
12     }
13 }
14 
15 class MyClassDerivedScheduler : Scheduler
16 {
17     void start(void delegate() op)
18     {
19     }
20 }
21 
22 struct MyAsyncScheduler
23 {
24     void start(void delegate() op)
25     {
26     }
27 
28     CancellationToken schedule(void delegate() op, Duration val)
29     {
30         return null;
31     }
32 }
33 
34 class MyClassAsyncScheduler
35 {
36     void start(void delegate() op)
37     {
38     }
39 
40     CancellationToken schedule(void delegate() op, Duration val)
41     {
42         return null;
43     }
44 }
45 
46 class MyClassPartAsyncScheduler : Scheduler
47 {
48     void start(void delegate() op)
49     {
50     }
51 
52     CancellationToken schedule(void delegate() op, Duration val)
53     {
54         return null;
55     }
56 }
57 
58 class MyClassDerivedAsyncScheduler : AsyncScheduler
59 {
60     void start(void delegate() op)
61     {
62     }
63 
64     CancellationToken schedule(void delegate() op, Duration val)
65     {
66         return null;
67     }
68 }
69 
70 auto s1 = MyScheduler();
71 auto s2 = new MyClassScheduler;
72 auto s3 = new MyClassDerivedScheduler;
73 auto s4 = MyAsyncScheduler();
74 auto s5 = new MyClassAsyncScheduler;
75 auto s6 = new MyClassPartAsyncScheduler;
76 auto s7 = new MyClassDerivedAsyncScheduler;
77 
78 Scheduler t1 = s1.schedulerObject();
79 Scheduler t2 = s2.schedulerObject();
80 Scheduler t3 = s3.schedulerObject();
81 AsyncScheduler t4 = s4.schedulerObject();
82 AsyncScheduler t5 = s5.schedulerObject();
83 AsyncScheduler t6 = s6.schedulerObject();
84 AsyncScheduler t7 = s7.schedulerObject();
85 
86 assert(t1 !is null);
87 assert(t2 !is null);
88 assert(t3 !is null);
89 assert(t4 !is null);
90 assert(t5 !is null);
91 assert(t6 !is null);
92 assert(t7 !is null);
93 
94 assert(t3 is s3);
95 assert(t7 is s7);
1 struct MyScheduler
2 {
3     void start(void delegate() op)
4     {
5         op();
6     }
7 }
8 
9 MyScheduler scheduler;
10 Scheduler wrapped = scheduler.schedulerObject();
11 assert(wrapped !is null);