main work function
push event to event listener if it exists
send signal to signal processor if it exists
1 struct TestStruct { double x, y; string info; immutable(int)[] data; } 2 auto ts = TestStruct( 3.14, 2.7, "hello", [ 2, 3, 4 ] ); 3 4 class TestElement: WorkElement 5 { 6 override void process(){} 7 } 8 9 class TestSignalProcessor : SignalProcessor 10 { void processSignal( in Signal s ) { assert( s.code == 0 ); } } 11 12 auto elem = new TestElement; 13 elem.setSignalProcessor( new TestSignalProcessor ); 14 15 elem.sendSignal( Signal(0) ); 16 17 size_t cnt = 0; 18 elem.setEventListener( new class EventProcessor { 19 void processEvent( in Event ev ) 20 { cnt++; assert( ev.as!TestStruct == ts ); } 21 }); 22 23 auto ev = Event( 8, ts ); 24 elem.pushEvent( ev ); 25 elem.pushEvent( const Event( ev ) ); 26 elem.pushEvent( shared Event( ev ) ); 27 elem.pushEvent( immutable Event( ev ) ); 28 elem.pushEvent( const shared Event( ev ) ); 29 elem.pushEvent( shared const Event( ev ) ); 30 elem.pushEvent( immutable shared Event( ev ) ); 31 elem.pushEvent( shared immutable Event( ev ) ); 32 assert( cnt == 8 );
Inner interpret of thread
action must be in: * preparation -> ctor * last actions before start -> process special input event * actions on pause -> process special input event * processing -> process * terminate all -> selfDestroy( external memory manager )