WorkElement

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 )

Members

Functions

getEventProcessors
EventProcessor[] getEventProcessors()
process
void process()

main work function

pushEvent
void pushEvent(in Event ev)

push event to event listener if it exists

sendCtrlSignal
void sendCtrlSignal(in CtrlSignal sg)

send signal to signal processor if it exists

setCtrlSignalProcessor
void setCtrlSignalProcessor(CtrlSignalProcessor sp)
setEventListener
void setEventListener(EventProcessor ep)

Inherited Members

From EventBus

pushEvent
void pushEvent(in Event)

From CtrlSignalBus

sendCtrlSignal
void sendCtrlSignal(in CtrlSignal)

Examples

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 : CtrlSignalProcessor
10 { void processCtrlSignal( in CtrlSignal s ) { assertEq( s.code, 0 ); } }
11 
12 auto elem = new TestElement;
13 elem.setCtrlSignalProcessor( new TestSignalProcessor );
14 
15 elem.sendCtrlSignal( CtrlSignal(0) );
16 
17 size_t cnt = 0;
18 elem.setEventListener( new class EventProcessor {
19     void processEvent( in Event ev )
20     { cnt++; assertEq( 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 assertEq( cnt, 8 );

Meta