struct MyDisposable
{
void dispose()
{
}
}
struct MyScheduler
{
MyDisposable schedule(void delegate() op, Duration val)
{
return MyDisposable();
}
}
class MyClassScheduler
{
Disposable schedule(void delegate() op, Duration val)
{
return null;
}
}
class MyClassDerivedScheduler : Scheduler
{
Disposable schedule(void delegate() op, Duration val)
{
return null;
}
}
static assert(isScheduler!MyScheduler);
static assert(isScheduler!MyClassScheduler);
static assert(isScheduler!MyClassDerivedScheduler);
auto s1 = MyScheduler();
auto s2 = new MyClassScheduler;
auto s3 = new MyClassDerivedScheduler;
Scheduler t1 = s1.schedulerObject();
Scheduler t2 = s2.schedulerObject();
Scheduler t3 = s3.schedulerObject();
assert(t1 !is null);
assert(t2 !is null);
assert(t3 !is null);
assert(t3 is s3);
struct MyScheduler
{
Disposable schedule(void delegate() op, Duration dueTime)
{
if (dueTime > Duration.zero)
Thread.sleep(dueTime);
op();
return NopDisposable.instance;
}
}
MyScheduler scheduler;
Scheduler wrapped = scheduler.schedulerObject();
assert(wrapped !is null);