Project
Loading...
Searching...
No Matches
o2::framework::CallbackService Class Reference

#include <CallbackService.h>

Public Types

enum struct  Id : int {
  Start = 0 , Stop , Reset , Idle ,
  ClockTick , DataConsumed , EndOfStream , RegionInfoCallback ,
  NewTimeslice , PreProcessing , FinaliseOutputs , PostProcessing ,
  CCDBDeserialised , DomainInfoUpdated , DeviceStateChanged , ExitRequested
}
 the defined processing steps at which a callback can be invoked More...
 
using StartCallback = std::function< void()>
 
using StopCallback = std::function< void()>
 
using ResetCallback = std::function< void()>
 
using IdleCallback = std::function< void()>
 
using ClockTickCallback = std::function< void()>
 
using DataConsumedCallback = std::function< void(ServiceRegistryRef)>
 
using EndOfStreamCallback = std::function< void(EndOfStreamContext &)>
 
using RegionInfoCallback = std::function< void(fair::mq::RegionInfo const &)>
 
using NewTimesliceCallback = std::function< void(o2::header::DataHeader &, DataProcessingHeader &)>
 
using PreProcessingCallback = std::function< void(ServiceRegistryRef, int)>
 
using FinaliseOutputsCallback = std::function< void(ServiceRegistryRef, int)>
 
using PostProcessingCallback = std::function< void(ServiceRegistryRef, int)>
 
using CCDBDeserializedCallback = std::function< void(ConcreteDataMatcher &, void *)>
 
using DomainInfoUpdatedCallback = std::function< void(ServiceRegistryRef, size_t timeslice, ChannelIndex index)>
 
using DeviceStateChangedCallback = std::function< void(ServiceRegistryRef, int newState)>
 
using ExitRequestedCallback = std::function< void(ServiceRegistryRef)>
 
using Callbacks = CallbackRegistry< Id, RegistryPair< Id, Id::Start, StartCallback >, RegistryPair< Id, Id::Stop, StopCallback >, RegistryPair< Id, Id::Reset, ResetCallback >, RegistryPair< Id, Id::Idle, IdleCallback >, RegistryPair< Id, Id::ClockTick, ClockTickCallback >, RegistryPair< Id, Id::DataConsumed, DataConsumedCallback >, RegistryPair< Id, Id::EndOfStream, EndOfStreamCallback >, RegistryPair< Id, Id::RegionInfoCallback, RegionInfoCallback >, RegistryPair< Id, Id::NewTimeslice, NewTimesliceCallback >, RegistryPair< Id, Id::PreProcessing, PreProcessingCallback >, RegistryPair< Id, Id::FinaliseOutputs, FinaliseOutputsCallback >, RegistryPair< Id, Id::PostProcessing, PostProcessingCallback >, RegistryPair< Id, Id::CCDBDeserialised, CCDBDeserializedCallback >, RegistryPair< Id, Id::DomainInfoUpdated, DomainInfoUpdatedCallback >, RegistryPair< Id, Id::DeviceStateChanged, DeviceStateChangedCallback >, RegistryPair< Id, Id::ExitRequested, ExitRequestedCallback > >
 

Public Member Functions

template<Id ID, typename U >
void set (U &&cb)
 
template<Id ID, typename... TArgs>
auto call (TArgs &&... args)
 

Static Public Attributes

static constexpr ServiceKind service_kind = ServiceKind::Global
 

Detailed Description

Definition at line 34 of file CallbackService.h.

Member Typedef Documentation

◆ Callbacks

◆ CCDBDeserializedCallback

◆ ClockTickCallback

Definition at line 94 of file CallbackService.h.

◆ DataConsumedCallback

◆ DeviceStateChangedCallback

Definition at line 104 of file CallbackService.h.

◆ DomainInfoUpdatedCallback

Definition at line 103 of file CallbackService.h.

◆ EndOfStreamCallback

◆ ExitRequestedCallback

◆ FinaliseOutputsCallback

◆ IdleCallback

Definition at line 93 of file CallbackService.h.

◆ NewTimesliceCallback

◆ PostProcessingCallback

◆ PreProcessingCallback

◆ RegionInfoCallback

using o2::framework::CallbackService::RegionInfoCallback = std::function<void(fair::mq::RegionInfo const&)>

Definition at line 97 of file CallbackService.h.

◆ ResetCallback

Definition at line 92 of file CallbackService.h.

◆ StartCallback

Definition at line 90 of file CallbackService.h.

◆ StopCallback

Definition at line 91 of file CallbackService.h.

Member Enumeration Documentation

◆ Id

the defined processing steps at which a callback can be invoked

Enumerator
Start 

Invoked before the inner loop is started

Stop 

Invoked when the device is about to be stoped

Reset 

Invoked on device rest

Idle 

Invoked when there was no computation scheduled

ClockTick 

Invoked every iteration of the inner loop

DataConsumed 

Invoked whenever data has been consumed

EndOfStream 

Invoked when we are notified that no further data will arrive. Notice that one could have more "EndOfData" notifications. Because we could be signaled by control that the data flow restarted.

RegionInfoCallback 

Invoked whenever FairMQ notifies us of a new region

return AlgorithmSpec::InitCallback{[=](InitContext& ic) {
   auto& callbacks = ic.services().get<CallbackService>();
   callbacks.set<CallbackService::Id::RegionInfoCallback>([](fair::mq::RegionInfo const& info) {
   ... do GPU init ...
   });
 }
 ...
 return [task](ProcessingContext& pc) {
   // your processing loop. Guaranteed to be called synchronously
   // with the callback
 };
}}; 
NewTimeslice 

Invoked whenever a new timeslice has been created from an enumeration. Users can override this to make sure the fill the DataHeader associated to a timeslice with the wanted quantities.

PreProcessing 

Invoked before the processing callback.

FinaliseOutputs 

Invoked after the processing callback and before the post processing callback to allow for injecting data in the output stream.

PostProcessing 

Invoked after the processing callback,.

CCDBDeserialised 

Invoked whenever an object from CCDB is deserialised via ROOT. Use this to finalise the initialisation of the object.

DomainInfoUpdated 

Invoked when new domain info is available.

DeviceStateChanged 

Invoked the device undergoes a state change.

ExitRequested 

Invoked when the device was requested to stop.

Definition at line 41 of file CallbackService.h.

Member Function Documentation

◆ call()

template<Id ID, typename... TArgs>
auto o2::framework::CallbackService::call ( TArgs &&...  args)
inline

Definition at line 134 of file CallbackService.h.

◆ set()

template<Id ID, typename U >
void o2::framework::CallbackService::set ( U &&  cb)
inline

Definition at line 127 of file CallbackService.h.

Member Data Documentation

◆ service_kind

constexpr ServiceKind o2::framework::CallbackService::service_kind = ServiceKind::Global
staticconstexpr

Callbacks are a global service because they will always be invoked by the main thread only.

Definition at line 39 of file CallbackService.h.


The documentation for this class was generated from the following file: