15#include <tbb/concurrent_queue.h>
18#define ON_DEBUG if ( outputLevel() <= MSG::DEBUG )
19#define ON_VERBOSE if ( outputLevel() <= MSG::VERBOSE )
21#define DEBMSG ON_DEBUG debug()
22#define VERMSG ON_VERBOSE verbose()
26 :
public extends<MinimalEventLoopMgr, Gaudi::Interfaces::IQueueingEventProcessor> {
28 using extends::extends;
35 using namespace std::chrono_literals;
36 push( std::move( ctx ) );
37 std::optional<ResultType> result;
38 while ( !( result =
pop() ) ) std::this_thread::sleep_for( 1ms );
39 return std::get<0>( std::move( *result ) );
54 std::optional<ResultType>
pop()
override {
56 if (
m_done.try_pop( out ) )
64 tbb::concurrent_bounded_queue<ResultType>
m_done;
72 std::tuple<StatusCode, EventContext> processEvent(
EventContext&& context );
101 auto ok = base_class::start();
102 if ( !ok )
return ok;
113 std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
131 bool eventfailed =
false;
137 if (
m_WB.isValid() )
m_WB->selectStore( context.slot() ).ignore();
152 sc = ita->sysExecute( context );
155 fatal() <<
".executeEvent(): Exception with tag=" << Exception.tag() <<
" thrown by " << ita->name() <<
endmsg;
157 }
catch (
const std::exception& Exception ) {
158 fatal() <<
".executeEvent(): Standard std::exception thrown by " << ita->name() <<
endmsg;
160 }
catch ( ... ) {
fatal() <<
".executeEvent(): UNKNOWN Exception thrown by " << ita->name() <<
endmsg; }
163 warning() <<
"Execution of algorithm " << ita->name() <<
" failed" <<
endmsg;
168 m_aess->updateEventStatus( eventfailed, context );
179 state.setFilterPassed(
true );
182 warning() <<
"Execution of output stream " << ito->name() <<
" failed" <<
endmsg;
190 error() <<
"Error processing event loop." <<
endmsg;
191 std::ostringstream ost;
192 m_aess->dump( ost, context );
193 DEBMSG <<
"Dumping AlgExecStateSvc status:\n" << ost.str() <<
endmsg;
197 return { std::move( outcome ), std::move( context ) };
205 return base_class::stop();
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
wrapper on an Algorithm state.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class represents an entry point to all the event specific data.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Implementation of property with value of concrete type.
tbb::concurrent_bounded_queue< ResultType > m_done
void push(EventContext &&ctx) override
bool empty() const override
Tell if the processor has events in the queues.
tbb::concurrent_bounded_queue< EventContext > m_incoming
std::thread m_evtLoopThread
StatusCode stop() override
Gaudi::Property< std::size_t > m_queueCapacity
std::optional< ResultType > pop() override
Get the next available result, if any.
std::tuple< StatusCode, EventContext > processEvent(EventContext &&context)
StatusCode executeEvent(EventContext &&ctx) override
std::atomic< std::size_t > m_inFlight
StatusCode start() override
Define general base for Gaudi exception.
The IProperty is the basic interface for all components which have properties that can be set or get.
ListAlg m_outStreamList
List of output streams.
AbortEventListener m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
SmartIF< IAlgExecStateSvc > m_aess
List of top level algorithms.
SmartIF< IHiveWhiteBoard > m_WB
< Event data service (whiteboard)
RetCodeGuard(const SmartIF< IProperty > &appmgr, int retcode)
SmartIF< IProperty > m_appmgr
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
void ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
Base class used to extend a class implementing other interfaces.
constexpr int UnhandledException
GAUDI_API void setCurrentContext(const EventContext *ctx)
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.