GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
TGo4BufferQueue Class Reference

#include <TGo4BufferQueue.h>

+ Inheritance diagram for TGo4BufferQueue:

Public Member Functions

 TGo4BufferQueue ()
 
 TGo4BufferQueue (const char *name)
 
void AddBufferFromObject (TObject *object)
 
void AddBuffer (TBuffer *buffer, Bool_t clone=kFALSE)
 
void FreeBuffer (TBuffer *buffer)
 
virtual void Clear (Option_t *opt="")
 
TBuffer * WaitBuffer ()
 
TObject * WaitObjectFromBuffer ()
 
virtual ~TGo4BufferQueue ()
 
- Public Member Functions inherited from TGo4Queue
 TGo4Queue (const char *name=0)
 
virtual ~TGo4Queue ()
 
virtual void Wake ()
 
Bool_t IsEmpty ()
 
Int_t GetEntries () const
 
void SetMaxEntries (Int_t max)
 

Static Public Member Functions

static TBuffer * CreateValueBuffer (UInt_t val)
 
static Int_t DecodeValueBuffer (TBuffer *buf)
 

Static Public Attributes

static const Int_t fgiISOWNER = BIT(14)
 

Private Member Functions

void InitBuffers ()
 
void Realloc (TBuffer *buffer, Int_t oldsize, Int_t newsize)
 
TBuffer * NewEntry ()
 

Private Attributes

TList * fxBufferList
 
TList * fxFreeList
 
TMutex * fxBufferMutex
 
Int_t fiOverflowcount
 
Int_t fiMaxBuffers
 

Additional Inherited Members

- Protected Member Functions inherited from TGo4Queue
TObject * Next ()
 
TObject * Wait ()
 
void Add (TObject *ob)
 

Detailed Description

Class containing a pointer queue for TBuffers. Is able to stream any external TObject into a TBuffer which then is added to the queue.

Definition at line 27 of file TGo4BufferQueue.h.

Constructor & Destructor Documentation

TGo4BufferQueue::TGo4BufferQueue ( )

Definition at line 38 of file TGo4BufferQueue.cxx.

References GO4TRACE, and InitBuffers().

TGo4BufferQueue::TGo4BufferQueue ( const char *  name)

Definition at line 51 of file TGo4BufferQueue.cxx.

References GO4TRACE, and InitBuffers().

TGo4BufferQueue::~TGo4BufferQueue ( )
virtual

Definition at line 80 of file TGo4BufferQueue.cxx.

References fxBufferList, fxBufferMutex, fxFreeList, and GO4TRACE.

Member Function Documentation

void TGo4BufferQueue::AddBuffer ( TBuffer *  buffer,
Bool_t  clone = kFALSE 
)

Add buffer pointer to queue. We Renamed the protected baseclass method to avoid user confusion. If clone is true, a clone (deep streamer copy) of the given buffer will be done and this clone is added to the queue.

Definition at line 145 of file TGo4BufferQueue.cxx.

References TGo4Queue::Add(), TGo4Log::Debug(), fiMaxBuffers, fxBufferList, fxBufferMutex, fxFreeList, GO4TRACE, NewEntry(), and Realloc().

Referenced by main(), TGo4StatusRunnable::Run(), TGo4DataRunnable::Run(), TGo4CommandRunnable::Run(), TGo4ServerTask::SendStatusBuffer(), TGo4Task::SendStatusBuffer(), TGo4Task::SendStopBuffers(), TGo4Task::SubmitEmergencyCommand(), and TGo4Task::SubmitEmergencyData().

void TGo4BufferQueue::AddBufferFromObject ( TObject *  object)

Reconstruct a TObject queue entry from a given TBuffer pointer. To be used for streaming the receiving socket contents into the queue. Operation should be thread locked by the calling user.

Definition at line 220 of file TGo4BufferQueue.cxx.

References TGo4Queue::Add(), GO4TRACE, and TGo4Buffer.

Referenced by TGo4ClientTask::AddLocalCommand(), TGo4Task::GetStatus(), main(), TGo4ExampleApplication::SendData(), TGo4Task::SendObject(), TGo4ServerTask::SendStatus(), TGo4Task::SendStatus(), TGo4ExampleServer::StopWorkThreads(), and TGo4Task::SubmitCommand().

void TGo4BufferQueue::Clear ( Option_t *  opt = "")
virtual

Empty the queue and give free buffers back

Reimplemented from TGo4Queue.

Definition at line 303 of file TGo4BufferQueue.cxx.

References FreeBuffer(), and TGo4Queue::Next().

Referenced by TGo4AnalysisProxy::ReceiveStatus().

TBuffer * TGo4BufferQueue::CreateValueBuffer ( UInt_t  val)
static

Create a root buffer that contains a single value val. This feature is used to wrap direct (emergency) commands into a TBuffer to send it via the taskhandler queues and sockets. Also used to indicate disconnect mode for the taskhandler threads.

Definition at line 360 of file TGo4BufferQueue.cxx.

References TGo4Buffer.

Referenced by TGo4Task::SubmitEmergencyCommand(), TGo4Task::SubmitEmergencyData(), and TGo4Task::TGo4Task().

Int_t TGo4BufferQueue::DecodeValueBuffer ( TBuffer *  buf)
static

Extract value from buffer that was created by CreateValueBuffer method. Used to decode a direct command or disconnect value that is received from queue or socket connection. Negative value means no valid value buffer.

Definition at line 371 of file TGo4BufferQueue.cxx.

Referenced by TGo4TaskHandlerRunnable::CheckStopBuffer().

void TGo4BufferQueue::FreeBuffer ( TBuffer *  buffer)

Free internal buffer to be re-used by the AddBuffer as clone method. To be used by the thread that got the buffer from WaitBuffer after working on it. If buffer does not belong to the internal buffers list of this queue, it is not added to the free buffer list.

Definition at line 267 of file TGo4BufferQueue.cxx.

References TGo4Socket::fgiBUFINITSIZE, fxBufferList, fxBufferMutex, fxFreeList, GO4TRACE, and Realloc().

Referenced by Clear(), TGo4StatusRunnable::Run(), TGo4DataRunnable::Run(), TGo4CommandRunnable::Run(), and WaitObjectFromBuffer().

void TGo4BufferQueue::InitBuffers ( )
private

Initialization of internal queue buffer.

Definition at line 64 of file TGo4BufferQueue.cxx.

References fiMaxBuffers, fxBufferList, fxBufferMutex, fxFreeList, GO4TRACE, and NewEntry().

Referenced by TGo4BufferQueue().

TBuffer * TGo4BufferQueue::NewEntry ( )
private

Create dummy buffer for queue.

Definition at line 345 of file TGo4BufferQueue.cxx.

References TGo4Socket::fgiBUFINITSIZE, and TGo4Buffer.

Referenced by AddBuffer(), and InitBuffers().

void TGo4BufferQueue::Realloc ( TBuffer *  buffer,
Int_t  oldsize,
Int_t  newsize 
)
private

Reallocate buffer of TBuffer to newsize.

Definition at line 313 of file TGo4BufferQueue.cxx.

References TGo4Socket::fgiBUFEXTRASPACE, and fgiISOWNER.

Referenced by AddBuffer(), and FreeBuffer().

TBuffer * TGo4BufferQueue::WaitBuffer ( )

Wait for buffer object from queue. We Renamed the protected baseclass method to avoid user confusion.

Definition at line 97 of file TGo4BufferQueue.cxx.

References GO4TRACE, and TGo4Queue::Wait().

Referenced by main(), TGo4StatusRunnable::Run(), TGo4DataRunnable::Run(), TGo4CommandRunnable::Run(), and WaitObjectFromBuffer().

TObject * TGo4BufferQueue::WaitObjectFromBuffer ( )

Wait for buffer object from queue. When buffer is received, object is reconstructed out of it (thread mainlock aqcuired!). NULL in case of unknown class.

Definition at line 104 of file TGo4BufferQueue.cxx.

References FreeBuffer(), GO4TRACE, and WaitBuffer().

Referenced by TGo4ServerTask::NextCommand(), TGo4Task::NextCommand(), TGo4Task::NextObject(), and TGo4Task::NextStatus().

Member Data Documentation

const Int_t TGo4BufferQueue::fgiISOWNER = BIT(14)
static

.we emulate the protected owner flag of the TBuffer class, needed for reallocation!

Definition at line 98 of file TGo4BufferQueue.h.

Referenced by Realloc().

Int_t TGo4BufferQueue::fiMaxBuffers
private

Number of preallocated buffer TBuffers (maximum entries in fxBufferList).

Definition at line 140 of file TGo4BufferQueue.h.

Referenced by AddBuffer(), and InitBuffers().

Int_t TGo4BufferQueue::fiOverflowcount
private

Definition at line 134 of file TGo4BufferQueue.h.

TList* TGo4BufferQueue::fxBufferList
private

List of preallocated buffer TBuffers which are used when TBuffer added to queue should be "cloned". Each AddBuffer with option clone will memcopy the input buffer char field to the next TBuffer field in this list. Output buffer after WaitBuffer is then this internal TBuffer, not the input TBuffer. If all buffer buffers are in use, no further buffer is allowed to be added as clone.

Definition at line 129 of file TGo4BufferQueue.h.

Referenced by AddBuffer(), FreeBuffer(), InitBuffers(), and ~TGo4BufferQueue().

TMutex* TGo4BufferQueue::fxBufferMutex
private

Definition at line 133 of file TGo4BufferQueue.h.

Referenced by AddBuffer(), FreeBuffer(), InitBuffers(), and ~TGo4BufferQueue().

TList* TGo4BufferQueue::fxFreeList
private

List of buffers which are free for the next add.

Definition at line 132 of file TGo4BufferQueue.h.

Referenced by AddBuffer(), FreeBuffer(), InitBuffers(), and ~TGo4BufferQueue().


The documentation for this class was generated from the following files: