ATLAS Offline Software
ONCRPCThreadCollection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef JIVEXML_ONCRPCTHREADCOLLECTION_H
6 #define JIVEXML_ONCRPCTHREADCOLLECTION_H
7 
8 #include <vector>
9 #include <pthread.h>
10 #include <semaphore.h>
11 
12 namespace JiveXML{
13 
17  class ThreadCollection : private std::vector<pthread_t> {
18 
19  public:
20 
21  //Constructor
23 
24  //Destructor
26 
29  //Add a thread
30  void AddThread( const pthread_t& thread );
31 
32  //Wait till the thread has been added
33  void WaitAdd();
34 
35  //Remove a thread
36  void RemoveThread( const pthread_t& thread );
37 
38  //Wait for all threads to finish
39  void JoinAll();
40 
41  //Return number of threads
42  //Can't be const as it requires mutex
43  int NumberOfThreads();
45 
46  private:
47  //mutex to assure no conflicts when adding/removing threads
48  pthread_mutex_t m_mutex;
49  //Semaphore to assure we add all threads
50  sem_t m_semaphore;
51  };
52 
53 }
54 #endif
55 
JiveXML::ThreadCollection
This class handles a collection of threads.
Definition: ONCRPCThreadCollection.h:17
JiveXML::ThreadCollection::ThreadCollection
ThreadCollection()
Definition: ONCRPCThreadCollection.cxx:11
JiveXML::ThreadCollection::NumberOfThreads
int NumberOfThreads()
Definition: ONCRPCThreadCollection.cxx:119
JiveXML::ThreadCollection::AddThread
void AddThread(const pthread_t &thread)
Definition: ONCRPCThreadCollection.cxx:34
JiveXML::ThreadCollection::m_mutex
pthread_mutex_t m_mutex
Definition: ONCRPCThreadCollection.h:48
JiveXML::ThreadCollection::JoinAll
void JoinAll()
Definition: ONCRPCThreadCollection.cxx:88
JiveXML::ThreadCollection::~ThreadCollection
~ThreadCollection()
Definition: ONCRPCThreadCollection.cxx:22
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
JiveXML::ThreadCollection::WaitAdd
void WaitAdd()
Definition: ONCRPCThreadCollection.cxx:51
JiveXML::ThreadCollection::m_semaphore
sem_t m_semaphore
Definition: ONCRPCThreadCollection.h:50
JiveXML::ThreadCollection::RemoveThread
void RemoveThread(const pthread_t &thread)
Definition: ONCRPCThreadCollection.cxx:58