ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXMLServer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef JIVEXML_JIVEXMLSERVER_H
6#define JIVEXML_JIVEXMLSERVER_H
7
17
18#include <future>
19#include <vector>
20#include <string>
21
22//athena includes
23#include <GaudiKernel/IMessageSvc.h>
24#include <GaudiKernel/StatusCode.h>
26
27//JiveXML includes
28#include <JiveXML/IServer.h>
29#include <JiveXML/EventStream.h>
30
31namespace JiveXML {
32
33 //Forward declarations
34 class ThreadCollection;
35
36 class JiveXMLServer: virtual public IServer {
37
38 public:
39 //Constructor with port number
40 JiveXMLServer( int port = 0 );
41
42 //Destructor
43 virtual ~JiveXMLServer();
44
47
48 virtual StatusCode UpdateEventForStream( const EventStreamID& evtStreamID, const std::string & event) override;
50
53
54 virtual std::vector<std::string> GetStreamNames() const override;
56 virtual const EventStreamID GetEventStreamID(const std::string& streamName) const override;
58 virtual const std::string GetEvent( const EventStreamID& evtStreamID ) const override;
60 virtual int GetState() const override;
62
64
66 virtual void Message( const MSG::Level level, const std::string& msg ) const override;
68 virtual MSG::Level LogLevel() const override;
70
73
74 StatusCode StartServingThread();
76 StatusCode StopServingThread();
78 virtual bool GetRunServerFlag () const override { return m_runServerThread; };
80 virtual void ServerThreadStopped() override;
82 void Wait();
84
85
86 private:
87
88 //Signal handler must be static function
89 static void signalHandler (int signum);
90
91 //Promise used to suspend main thread while server thread is
92 //running. The semaphore will reach its post-condition either by
93 // a) receiving a signal through the signal handler
94 // b) the ServerThreadStopped callback being called
95 inline static std::promise<int> m_receivedSignal ATLAS_THREAD_SAFE;
96
97 //Port number property - defaults to zero in which case
98 //it is dynamically assigned
100
101 //A map of the streams and their current events
103
104 //A mutex (mutual exclusive) lock for the data map
105 mutable pthread_mutex_t m_accessLock ATLAS_THREAD_SAFE;
106
107 //A handle to the server thread
109
110 //Once this flag is set to false, the thread will stop after handling its
111 //last request
113 };
114}
115
116#endif
Define macros for attributes used to control the static checker.
For the client-server communication, each event is uniquely identified by the run number,...
Definition EventStream.h:19
Pure abstract interface for all full server implementations.
Definition IServer.h:22
virtual bool GetRunServerFlag() const override
The server thread will stop once this flag is set to false.
static std::promise< int > m_receivedSignal ATLAS_THREAD_SAFE
virtual StatusCode UpdateEventForStream(const EventStreamID &evtStreamID, const std::string &event) override
Put this event as new current event for stream given by name.
virtual ~JiveXMLServer()
Destructor.
virtual std::vector< std::string > GetStreamNames() const override
get the names of all the streams
virtual void Message(const MSG::Level level, const std::string &msg) const override
This function is exposed to allow using ERS messaging service from other threads.
virtual MSG::Level LogLevel() const override
Get the logging level.
virtual void ServerThreadStopped() override
Callback whenever the server thread is stopped.
static void signalHandler(int signum)
When the signal handler is called, switch the lock to the post condition.
StatusCode StartServingThread()
Start the serving thread.
void Wait()
Wait for the server finish.
EventStreamMap m_eventStreamMap
StatusCode StopServingThread()
Stop the serving thread.
JiveXMLServer(int port=0)
Constructor.
virtual int GetState() const override
get the Status of the application
virtual const std::string GetEvent(const EventStreamID &evtStreamID) const override
get the current event for a particular stream
virtual const EventStreamID GetEventStreamID(const std::string &streamName) const override
get the current EventStreamID for a particular stream
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< const EventStreamID, const std::string > EventStreamMap
Definition EventStream.h:87
MsgStream & msg
Definition testRead.cxx:32