GSI Object Oriented Online Offline (Go4)
GO4-5.3.0
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Go4Queue
TGo4Queue.cxx
Go to the documentation of this file.
1
// $Id: TGo4Queue.cxx 999 2013-07-25 11:58:59Z linev $
2
//-----------------------------------------------------------------------
3
// The GSI Online Offline Object Oriented (Go4) Project
4
// Experiment Data Processing at EE department, GSI
5
//-----------------------------------------------------------------------
6
// Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
7
// Planckstr. 1, 64291 Darmstadt, Germany
8
// Contact: http://go4.gsi.de
9
//-----------------------------------------------------------------------
10
// This software can be used under the license agreements as stated
11
// in Go4License.txt file which is part of the distribution.
12
//-----------------------------------------------------------------------
13
14
#include "
TGo4Queue.h
"
15
16
#include "TList.h"
17
#include "TMutex.h"
18
#include "TCondition.h"
19
20
#include "
TGo4Log.h
"
21
#include "TGo4LockGuard.h"
22
#include "
TGo4RuntimeException.h
"
23
24
TGo4Queue::TGo4Queue
(
const
char
* name) :
25
TNamed(name ? name :
"Default Queue"
,
"This is a Go4 Queue"
),
26
fiEntries(0),
27
fiMaxEntries(100),
28
fbWakeUpCall(kFALSE)
29
{
30
fxMutex
=
new
TMutex;
31
fxCondition
=
new
TCondition;
32
fxList
=
new
TList;
33
}
34
35
TGo4Queue::~TGo4Queue
()
36
{
37
delete
fxList
;
fxList
= 0;
38
delete
fxCondition
;
fxCondition
= 0;
39
delete
fxMutex
;
fxMutex
= 0;
40
}
41
42
void
TGo4Queue::Clear
(Option_t* opt)
43
{
44
TGo4LockGuard
qguard(
fxMutex
);
45
fxList
->Clear();
46
}
47
48
TObject*
TGo4Queue::Wait
()
49
{
50
if
(
IsEmpty
()) {
51
//std::cout <<"WWWWWWWWWWWWWWWWWW --- TGo4Queue "<< GetName() <<" is in Condition Wait..." << std::endl;
52
fxCondition
->Wait();
53
if
(
fbWakeUpCall
) {
54
fbWakeUpCall
= kFALSE;
55
return
0;
// signal by Wake(), give null back!
56
}
57
}
58
return
Next
();
59
}
60
61
TObject*
TGo4Queue::Next
()
62
{
63
TGo4LockGuard
qguard(
fxMutex
);
64
return
(
fxList
->Remove(
fxList
->LastLink()) );
65
}
66
67
void
TGo4Queue::Add
(TObject* ob)
68
{
69
{
70
TGo4LockGuard
qguard(
fxMutex
);
71
if
(
fxList
->GetSize() <=
fiMaxEntries
)
72
{
73
fxList
->AddFirst(ob);
74
//std::cout <<"QA Queue " <<GetName() <<" added obj, size="<<fxList->GetSize()<< std::endl;
75
}
76
else
77
{
78
//std::cout <<" Queue Add Error: queue "<< GetName() <<" is full !!!"<< std::endl;
79
throw
TGo4RuntimeException
();
80
}
81
}
//TGo4LockGuard qguard(fxMutex);
82
fxCondition
->Signal();
83
}
84
85
Bool_t
TGo4Queue::IsEmpty
()
86
{
87
TGo4LockGuard
qguard(
fxMutex
);
88
return
fxList
->IsEmpty();
89
}
90
91
void
TGo4Queue::Wake
()
92
{
93
//std::cout <<"TGo4Queue::Wake() in "<<GetName() << std::endl;
94
fbWakeUpCall
= kTRUE;
95
fxCondition
->Signal();
96
}
TGo4Queue::Add
void Add(TObject *ob)
Definition:
TGo4Queue.cxx:67
TGo4LockGuard
Definition:
TGo4LockGuard.h:40
TGo4Queue::TGo4Queue
TGo4Queue(const char *name=0)
Definition:
TGo4Queue.cxx:24
TGo4Queue.h
TGo4Queue::Wake
virtual void Wake()
Definition:
TGo4Queue.cxx:91
TGo4Queue::fbWakeUpCall
Bool_t fbWakeUpCall
Definition:
TGo4Queue.h:58
TGo4Queue::~TGo4Queue
virtual ~TGo4Queue()
Definition:
TGo4Queue.cxx:35
TGo4Queue::fxMutex
TMutex * fxMutex
Definition:
TGo4Queue.h:53
TGo4Log.h
TGo4Queue::IsEmpty
Bool_t IsEmpty()
Definition:
TGo4Queue.cxx:85
TGo4Queue::fxCondition
TCondition * fxCondition
Definition:
TGo4Queue.h:54
TGo4RuntimeException
Definition:
TGo4RuntimeException.h:19
TGo4RuntimeException.h
TGo4Queue::fiMaxEntries
Int_t fiMaxEntries
Definition:
TGo4Queue.h:57
TGo4Queue::Wait
TObject * Wait()
Definition:
TGo4Queue.cxx:48
TGo4Queue::fxList
TList * fxList
Definition:
TGo4Queue.h:55
TGo4Queue::Clear
virtual void Clear(Option_t *opt="")
Definition:
TGo4Queue.cxx:42
TGo4Queue::Next
TObject * Next()
Definition:
TGo4Queue.cxx:61
Generated on Mon Mar 5 2018 16:09:56 for GSI Object Oriented Online Offline (Go4) by
1.8.8