eventcore.core 12/14(85%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
238
248
250
260
270
280
290
309
318
328
338
340
350
360
370
380
390
409
418
428
430
440
450
460
470
481
491
501
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
module eventcore.core; public import eventcore.driver; import eventcore.drivers.posix.select; import eventcore.drivers.posix.epoll; import eventcore.drivers.posix.kqueue; import eventcore.drivers.libasync; import eventcore.drivers.winapi.driver; version (EventcoreEpollDriver) alias NativeEventDriver = EpollEventDriver; else version (EventcoreKqueueDriver) alias NativeEventDriver = KqueueEventDriver; else version (EventcoreWinAPIDriver) alias NativeEventDriver = WinAPIEventDriver; else version (EventcoreLibasyncDriver) alias NativeEventDriver = LibasyncEventDriver; else version (EventcoreSelectDriver) alias NativeEventDriver = SelectEventDriver; else alias NativeEventDriver = EventDriver; @property NativeEventDriver eventDriver() @safe @nogc nothrow { static if (is(NativeEventDriver == EventDriver)) assert(s_driver !is null, "setupEventDriver() was not called for this thread."); else assert(s_driver !is null, "eventcore.core static constructor didn't run!?"); return s_driver; } static if (!is(NativeEventDriver == EventDriver)) { static this() { if (!s_isMainThread) { if (!s_initCount++) { assert(s_driver is null); s_driver = new NativeEventDriver; } } } static ~this() { if (!s_isMainThread) { if (!--s_initCount) s_driver.dispose(); } } shared static this() { if (!s_initCount++) { s_driver = new NativeEventDriver; s_isMainThread = true; } } shared static ~this() { if (!--s_initCount) { s_driver.dispose(); } } } else { void setupEventDriver(EventDriver driver) { assert(driver !is null, "The event driver instance must be non-null."); assert(!s_driver, "Can only set up the event driver once per thread."); s_driver = driver; } } private { NativeEventDriver s_driver; bool s_isMainThread; // keeps track of nested DRuntime initializations that happen when // (un)loading shared libaries. int s_initCount = 0; }