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

sendSignal
void sendSignal(in Signal sg)

send signal to signal processor if it exists

setEventListener
void setEventListener(EventProcessor ep)
setSignalProcessor
void setSignalProcessor(SignalProcessor sp)

Inherited Members

From EventBus

pushEvent
void pushEvent(in Event)

From SignalBus

sendSignal
void sendSignal(in Signal)

From ExternalMemoryManager

isDestroyed
bool isDestroyed [@property setter]
selfConstruct
void selfConstruct()
selfDestroy
void selfDestroy()
preChildsDestroy
void preChildsDestroy()
isDestroyed
bool isDestroyed [@property getter]
registerChildEMM
T registerChildEMM(T obj, bool if_orphan = false)
registerChildEMM
T[] registerChildEMM(T[] objs, bool if_orphan = false)
newEMM
T newEMM(Args args)
destroy
void destroy()
EMM
mixin template EMM(string file = __FILE__, size_t line = __LINE__)

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 : 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 );

Meta