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 <mutex>
20#include <vector>
21#include <string>
22
23//athena includes
24#include <GaudiKernel/IMessageSvc.h>
25#include <GaudiKernel/StatusCode.h>
27
28//JiveXML includes
29#include <JiveXML/IServer.h>
30#include <JiveXML/EventStream.h>
31
32namespace JiveXML {
33
34 //Forward declarations
35 class ThreadCollection;
36
37 class JiveXMLServer: virtual public IServer {
38
39 public:
40 //Constructor with port number
41 JiveXMLServer( int port = 0 );
42
43 //Destructor
44 virtual ~JiveXMLServer();
45
48
49 virtual StatusCode UpdateEventForStream( const EventStreamID& evtStreamID, const std::string & event) override;
51
54
55 virtual std::vector<std::string> GetStreamNames() const override;
57 virtual const EventStreamID GetEventStreamID(const std::string& streamName) const override;
59 virtual const std::string GetEvent( const EventStreamID& evtStreamID ) const override;
61 virtual int GetState() const override;
63
65
67 virtual void Message( const MSG::Level level, const std::string& msg ) const override;
69 virtual MSG::Level LogLevel() const override;
71
74
75 StatusCode StartServingThread();
77 StatusCode StopServingThread();
79 virtual bool GetRunServerFlag () const override { return m_runServerThread; };
81 virtual void ServerThreadStopped() override;
83 void Wait();
85
86
87 private:
88
89 //Signal handler must be static function
90 static void signalHandler (int signum);
91
92 //Promise used to suspend main thread while server thread is
93 //running. The semaphore will reach its post-condition either by
94 // a) receiving a signal through the signal handler
95 // b) the ServerThreadStopped callback being called
96 inline static std::promise<int> m_receivedSignal ATLAS_THREAD_SAFE;
97
98 //Port number property - defaults to zero in which case
99 //it is dynamically assigned
101
102 //A map of the streams and their current events
104
105 //A mutex (mutual exclusive) lock for the data map
106 mutable std::timed_mutex m_accessLock ATLAS_THREAD_SAFE;
107
108 //A handle to the server thread
110
111 //Once this flag is set to false, the thread will stop after handling its
112 //last request
114 };
115}
116
117#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