53 {
54
55 const std::size_t n_of_batches = 2;
56 const std::size_t evts_in_batch = 5;
57
58
59 app->initialize().ignore();
60
61
62 MsgStream
log(
app.as<IMessageSvc>(),
"<main>" );
63
64
67
68 app->start().ignore();
69
70
71 {
72
73 SmartIF<Gaudi::Interfaces::IQueueingEventProcessor> qep{
app };
74
75
76
77 std::queue<EventContext> ready;
78
79 std::size_t evt_count = 0;
80
81
82 for ( std::size_t batch = 1; batch <= n_of_batches; ++batch ) {
83
85 if ( batch == 2 ) {
86 log <<
MSG::INFO <<
" (pretend we need time so that the processing thread drains the input queue)"
88 sleep_for( 4s );
89 log <<
MSG::INFO <<
" (all events in the queue should have been processed by now)" <<
endmsg;
90 }
91 for ( std::size_t i = 0; i < evts_in_batch; ++i ) {
92
93 auto ctx = qep->createEventContext();
94
95
96 ready.push( std::move( ctx ) );
97 }
98
99
101 while ( !ready.empty() ) {
102 ++evt_count;
103 log <<
MSG::INFO <<
"- pushing event " << evt_count <<
" (" << ready.front() <<
")..." <<
endmsg;
104 qep->push( std::move( ready.front() ) );
105 ready.pop();
107
108
110 if ( auto result = qep->pop() ) {
111
112 auto&& [sc,
ctx] = std::move( *result );
114 }
115 }
116 }
118 while ( !qep->empty() ) {
119 if ( auto result = qep->pop() ) {
120 auto&& [sc,
ctx] = std::move( *result );
122 } else {
123 sleep_for( 10ms );
124 }
125 }
126
127
129 }
130
131
132 app->stop().ignore();
133 app->finalize().ignore();
134
135
137 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.