GSI Object Oriented Online Offline (Go4)
GO4-6.1.2
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 2754 2020-04-16 11:13:50Z 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 fuer 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 "TGo4LockGuard.h"
21
#include "
TGo4RuntimeException.h
"
22
23
TGo4Queue::TGo4Queue
(
const
char
* name) :
24
TNamed(name ? name :
"Default Queue"
,
"This is a Go4 Queue"
),
25
fiEntries(0),
26
fiMaxEntries(100),
27
fbWakeUpCall(kFALSE)
28
{
29
fxMutex
=
new
TMutex;
30
fxCondition
=
new
TCondition;
31
fxList
=
new
TList;
32
}
33
34
TGo4Queue::~TGo4Queue
()
35
{
36
37
//printf ("JAM*************** DTOR of TGo4Queue %s BEGIN\n", GetName());
38
delete
fxList
;
fxList
= 0;
39
delete
fxCondition
;
fxCondition
= 0;
40
delete
fxMutex
;
fxMutex
= 0;
41
// printf ("JAM*************** DTOR of TGo4Queue %s END\n", GetName());
42
}
43
44
void
TGo4Queue::Clear
(Option_t* opt)
45
{
46
TGo4LockGuard
qguard(
fxMutex
);
47
fxList
->Clear();
48
}
49
50
TObject*
TGo4Queue::Wait
()
51
{
52
if
(
IsEmpty
()) {
53
// std::cout <<"WWWWWWWWWWWWWWWWWW --- TGo4Queue "<< GetName() <<" is in Condition Wait..." << std::endl;
54
fxCondition
->Wait();
55
if
(
fbWakeUpCall
) {
56
fbWakeUpCall
= kFALSE;
57
return
0;
// signal by Wake(), give null back!
58
}
59
}
60
return
Next
();
61
}
62
63
TObject*
TGo4Queue::Next
()
64
{
65
TGo4LockGuard
qguard(
fxMutex
);
66
return
(
fxList
->Remove(
fxList
->LastLink()) );
67
}
68
69
void
TGo4Queue::Add
(TObject* ob)
70
{
71
{
72
TGo4LockGuard
qguard(
fxMutex
);
73
if
(
fxList
->GetSize() <=
fiMaxEntries
) {
74
fxList
->AddFirst(ob);
75
// std::cout <<"QA Queue " <<GetName() <<" added obj, size="<<fxList->GetSize()<< std::endl;
76
}
else
{
77
// std::cout <<" Queue Add Error: queue "<< GetName() <<" is full !!!"<< std::endl;
78
throw
TGo4RuntimeException
();
79
}
80
}
// TGo4LockGuard qguard(fxMutex);
81
fxCondition
->Signal();
82
}
83
84
Bool_t
TGo4Queue::IsEmpty
()
85
{
86
TGo4LockGuard
qguard(
fxMutex
);
87
return
fxList
->IsEmpty();
88
}
89
90
void
TGo4Queue::Wake
()
91
{
92
//std::cout <<"TGo4Queue::Wake() in "<<GetName() << std::endl;
93
fbWakeUpCall
= kTRUE;
94
fxCondition
->Signal();
95
}
TGo4Queue::Add
void Add(TObject *ob)
Definition:
TGo4Queue.cxx:69
TGo4LockGuard
Definition:
TGo4LockGuard.h:40
TGo4Queue::TGo4Queue
TGo4Queue(const char *name=0)
Definition:
TGo4Queue.cxx:23
TGo4Queue.h
TGo4Queue::Wake
virtual void Wake()
Definition:
TGo4Queue.cxx:90
TGo4Queue::fbWakeUpCall
Bool_t fbWakeUpCall
Definition:
TGo4Queue.h:58
TGo4Queue::~TGo4Queue
virtual ~TGo4Queue()
Definition:
TGo4Queue.cxx:34
TGo4Queue::fxMutex
TMutex * fxMutex
Definition:
TGo4Queue.h:53
TGo4Queue::IsEmpty
Bool_t IsEmpty()
Definition:
TGo4Queue.cxx:84
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:50
TGo4Queue::fxList
TList * fxList
Definition:
TGo4Queue.h:55
TGo4Queue::Clear
virtual void Clear(Option_t *opt="")
Definition:
TGo4Queue.cxx:44
TGo4Queue::Next
TObject * Next()
Definition:
TGo4Queue.cxx:63
Generated on Thu Jun 17 2021 15:44:26 for GSI Object Oriented Online Offline (Go4) by
1.8.8