JANA2
C++ framework for multi-threaded data processing
|
JANA application class. More...
#include <JApplicationFwd.h>
Public Types | |
enum class | ExitCode { Success =0 , UnhandledException , Timeout , Segfault =139 } |
These exit codes are what JANA uses internally. More... | |
Public Member Functions | |
JApplication (JParameterManager *params=nullptr) | |
JApplication (JLogger::Level verbosity) | |
void | AddPlugin (std::string plugin_name) |
void | AddPluginPath (std::string path) |
void | Add (std::string event_source_name) |
void | Add (JEventSourceGenerator *source_generator) |
void | Add (JFactoryGenerator *factory_generator) |
void | Add (JEventSource *event_source) |
void | Add (JEventProcessor *processor) |
void | Add (JEventUnfolder *unfolder) |
void | Initialize (void) |
void | Run (bool wait_until_stopped=true, bool finish=true) |
Run the application, launching 1 or more threads to do the work. More... | |
void | Scale (int nthreads) |
void | Stop (bool wait_until_stopped=false, bool finish=true) |
void | Inspect () |
void | Quit (bool skip_join=false) |
void | SetExitCode (int exitCode) |
int | GetExitCode () |
void | PrintStatus () |
bool | IsInitialized (void) |
bool | IsQuitting (void) |
bool | IsDrainingQueues () |
void | SetTicker (bool ticker_on=true) |
bool | IsTickerEnabled () |
void | SetTimeoutEnabled (bool enabled=true) |
bool | IsTimeoutEnabled () |
uint64_t | GetNThreads () |
Returns the number of threads currently being used. | |
uint64_t | GetNEventsProcessed () |
Returns the number of events processed since Run() was called. | |
float | GetIntegratedRate () |
Returns the total integrated throughput so far in Hz since Run() was called. | |
float | GetInstantaneousRate () |
Returns the 'instantaneous' throughput in Hz since the last such call was made. | |
const JComponentSummary & | GetComponentSummary () |
JParameterManager * | GetJParameterManager () |
template<typename T > | |
T | GetParameterValue (std::string name) |
A convenience method which delegates to JParameterManager. | |
template<typename T > | |
JParameter * | GetParameter (std::string name, T &val) |
template<typename T > | |
JParameter * | SetParameterValue (std::string name, T val) |
A convenience method which delegates to JParameterManager. | |
template<typename T > | |
JParameter * | SetDefaultParameter (std::string name, T &val, std::string description="") |
template<typename T > | |
T | RegisterParameter (std::string name, const T default_val, std::string description="") |
template<typename T > | |
std::shared_ptr< T > | GetService () |
Use this in EventSources, Factories, or EventProcessors. More... | |
template<typename T > | |
void | ProvideService (std::shared_ptr< T > service) |
Call this from InitPlugin. More... | |
JANA application class.
The JApplication class serves as a central access point for getting to most things in the JANA application. It owns the JThreadManager, JParameterManager, etc. It is also responsible for making sure all of the plugins are attached and other user specified configurations for the run are implemented before starting the processing of the data. User code (e.g. plugins) will generally register things like event sources and processors with the JApplication so they can be called up later at the appropriate time.
|
strong |
These exit codes are what JANA uses internally.
However they are fundamentally a suggestion – the user code is likely to use arbitrary exit codes.
void JApplication::Add | ( | JEventProcessor * | processor | ) |
Adds the given JEventProcessor to the JANA context. Ownership is passed to JComponentManager.
void JApplication::Add | ( | JEventSource * | event_source | ) |
Adds the given JEventSource to the JANA context. Ownership is passed to JComponentManager.
void JApplication::Add | ( | JEventSourceGenerator * | source_generator | ) |
Adds the given JEventSourceGenerator to the JANA context. Ownership is passed to JComponentManager.
void JApplication::Add | ( | JEventUnfolder * | unfolder | ) |
Adds the given JEventUnfolder to the JANA context. Ownership is passed to JComponentManager.
void JApplication::Add | ( | JFactoryGenerator * | factory_generator | ) |
Adds the given JFactoryGenerator to the JANA context. Ownership is passed to JComponentManager.
void JApplication::Add | ( | std::string | event_source_name | ) |
Adds the event source name (e.g. a file or socket name) to the JANA context. JANA will instantiate the corresponding JEventSource using a user-provided JEventSourceGenerator.
const JComponentSummary & JApplication::GetComponentSummary | ( | ) |
Returns a data object describing all components currently running
int JApplication::GetExitCode | ( | ) |
Returns the currently set exit code. This can be used by JProcessor/JFactory classes to communicate an appropriate exit code that a jana program can return upon exit. The value can be set via the SetExitCode method.
std::shared_ptr< T > JApplication::GetService |
Use this in EventSources, Factories, or EventProcessors.
A convenience method which delegates to JServiceLocator.
Do not call this from InitPlugin(), as not all JServices may have been loaded yet. When initializing a Service, use acquire_services() instead.
Referenced by JSignalHandler::handle_sigint(), and JGeometryXML::JGeometryXML().
void JApplication::Initialize | ( | void | ) |
Initialize the application in preparation for data processing. This is called by the Run method so users will usually not need to call this directly.
References JCpuInfo::GetNumCpus(), and ProvideService().
Referenced by Run().
void JApplication::ProvideService | ( | std::shared_ptr< T > | service | ) |
Call this from InitPlugin.
A convenience method which delegates to JServiceLocator.
Referenced by Initialize().
void JApplication::Run | ( | bool | wait_until_stopped = true , |
bool | finish = true |
||
) |
Run the application, launching 1 or more threads to do the work.
This will initialize the application, attaching plugins etc. and launching threads to process events/time slices. This will then either return immediately (if wait_until_finish=false) or enter a lazy loop checking the progress of the data processing (if wait_until_finish=true).
In the wait_until_finished
mode, this will run continuously until the JProcessingController indicates it is finished or stopped or some other condition exists that would cause it to end early. Under normal conditions, the data processing stops when polling JProcessingController::is_finished() indicates the JArrowTopology is in the JArrowTopology::Status::Finished
state. This will occur when all event sources have been exhausted and all events have been processed such that all JWorkers have stopped.
See JProcessingController::run() for more details.
[in] | wait_until_finished | If true (default) do not return until the work has completed. |
References Initialize().
void JApplication::SetExitCode | ( | int | exitCode | ) |
Set a value of the exit code in that can be later retrieved using GetExitCode. This is so the executable can return a meaningful error code if processing is stopped prematurely, but the program is able to stop gracefully without a hard exit. See also GetExitCode.