ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXMLServer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef JIVEXML_JIVEXMLSERVER_H
6#define JIVEXML_JIVEXMLSERVER_H
7
17
18#include <vector>
19#include <string>
20
21//athena includes
22#include <GaudiKernel/IMessageSvc.h>
23#include <GaudiKernel/StatusCode.h>
25
26//JiveXML includes
27#include <JiveXML/IServer.h>
28#include <JiveXML/EventStream.h>
29
30//tdaq includes
31#include <owl/semaphore.h>
32
33namespace JiveXML {
34
35 //Forward declarations
36 class ThreadCollection;
37
38 class JiveXMLServer: virtual public IServer {
39
40 public:
41 //Constructor with port number
42 JiveXMLServer( int port = 0 );
43
44 //Destructor
45 virtual ~JiveXMLServer();
46
49
50 virtual StatusCode UpdateEventForStream( const EventStreamID& evtStreamID, const std::string & event) override;
52
55
56 virtual std::vector<std::string> GetStreamNames() const override;
58 virtual const EventStreamID GetEventStreamID(const std::string& streamName) const override;
60 virtual const std::string GetEvent( const EventStreamID& evtStreamID ) const override;
62 virtual int GetState() const override;
64
66
68 virtual void Message( const MSG::Level level, const std::string& msg ) const override;
70 virtual MSG::Level LogLevel() const override;
72
75
76 StatusCode StartServingThread();
78 StatusCode StopServingThread();
80 virtual bool GetRunServerFlag () const override { return m_runServerThread; };
82 virtual void ServerThreadStopped() override;
84 void Wait();
86
87
88 private:
89
90 //Signal handler must be static function
91 static void signalHandler (int signum);
92
93 //Static semaphore used to suspend main thread while server thread is
94 //running. The semaphore will reach its post-condition either by
95 // a) receiving a signal through the signal handler
96 // b) the ServerThreadStopped callback being called
97 inline static OWLSemaphore m_lock ATLAS_THREAD_SAFE;
98
99 //Store the received signal in a static member
100 inline static std::atomic<int> m_receivedSignal{0};
101
102 //Port number property - defaults to zero in which case
103 //it is dynamically assigned
105
106 //A map of the streams and their current events
108
109 //A mutex (mutual exclusive) lock for the data map
110 mutable pthread_mutex_t m_accessLock ATLAS_THREAD_SAFE;
111
112 //A handle to the server thread
114
115 //Once this flag is set to false, the thread will stop after handling its
116 //last request
118 };
119}
120
121#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.
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 std::atomic< int > m_receivedSignal
static void signalHandler(int signum)
When the signal handler is called, switch the lock to the post condition.
static OWLSemaphore m_lock ATLAS_THREAD_SAFE
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