CMS 3D CMS Logo

Public Member Functions | Private Attributes

stor::DiskWriterResources Class Reference

#include <DiskWriterResources.h>

List of all members.

Public Member Functions

 DiskWriterResources ()
bool isBusy ()
void requestStreamConfiguration (EvtStrConfigListPtr const, ErrStrConfigListPtr const, DiskWritingParams const &, unsigned int const &runNumber, boost::posix_time::time_duration const &timeoutValue)
void requestStreamDestruction ()
void setBusy (bool isBusyFlag)
void streamChangeDone ()
virtual bool streamChangeOngoing ()
bool streamChangeRequested (bool &doConfig, EvtStrConfigListPtr &, ErrStrConfigListPtr &, DiskWritingParams &dwParams, unsigned int &runNumber, boost::posix_time::time_duration &timeoutValue)
virtual void waitForStreamChange ()
virtual ~DiskWriterResources ()

Private Attributes

bool configurationIsNeeded_
bool diskWriterIsBusy_
bool fileClosingTestIsNeeded_
DiskWritingParams requestedDiskWritingParams_
ErrStrConfigListPtr requestedErrorStreamConfig_
EvtStrConfigListPtr requestedEventStreamConfig_
unsigned int requestedRunNumber_
boost::posix_time::time_duration requestedTimeout_
boost::condition streamChangeCondition_
bool streamChangeInProgress_
bool streamChangeIsNeeded_
boost::mutex streamChangeMutex_

Detailed Description

Container class for resources that are needed by the DiskWriter and need to be accessed from multiple threads.

Author:
mommsen
Revision:
1.9
Date:
2011/03/07 15:31:31

Definition at line 32 of file DiskWriterResources.h.


Constructor & Destructor Documentation

stor::DiskWriterResources::DiskWriterResources ( )

Constructs a DiskWriterResources instance.

Definition at line 8 of file DiskWriterResources.cc.

virtual stor::DiskWriterResources::~DiskWriterResources ( ) [inline, virtual]

Destructor.

Definition at line 44 of file DiskWriterResources.h.

{}

Member Function Documentation

bool stor::DiskWriterResources::isBusy ( )

Tests if the DiskWriter is currently busy..

Definition at line 107 of file DiskWriterResources.cc.

References diskWriterIsBusy_.

  {
    //boost::mutex::scoped_lock sl(generalMutex_);
    return diskWriterIsBusy_;
  }
void stor::DiskWriterResources::requestStreamConfiguration ( EvtStrConfigListPtr const  evtStrConfig,
ErrStrConfigListPtr const  errStrConfig,
DiskWritingParams const &  dwParams,
unsigned int const &  runNumber,
boost::posix_time::time_duration const &  timeoutValue 
)

Requests that the DiskWriter streams be configured with the specified configurations. Also allows new DiskWritingParams, run number and dequeue timeout values to be specified. Existing stream configurations will be discarded.

Definition at line 18 of file DiskWriterResources.cc.

References ExpressReco_HICollisions_FallBack::runNumber.

void stor::DiskWriterResources::requestStreamDestruction ( )

Requests that the DiskWriter streams be destroyed. Any pending stream configuraton request will be cancelled.

Definition at line 37 of file DiskWriterResources.cc.

References configurationIsNeeded_, streamChangeIsNeeded_, and streamChangeMutex_.

  {
    boost::mutex::scoped_lock sl(streamChangeMutex_);
    configurationIsNeeded_ = false;
    streamChangeIsNeeded_ = true;
  }
void stor::DiskWriterResources::setBusy ( bool  isBusyFlag)

Sets the DiskWriter "busy" status to the specified state.

Definition at line 101 of file DiskWriterResources.cc.

References diskWriterIsBusy_.

  {
    //boost::mutex::scoped_lock sl(generalMutex_);
    diskWriterIsBusy_ = isBusyFlag;
  }
void stor::DiskWriterResources::streamChangeDone ( )

Indicates that the stream configuration change is done.

Definition at line 91 of file DiskWriterResources.cc.

References streamChangeCondition_, streamChangeInProgress_, and streamChangeMutex_.

  {
    boost::mutex::scoped_lock sl(streamChangeMutex_);
    if (streamChangeInProgress_)
      {
        streamChangeCondition_.notify_one();
      }
    streamChangeInProgress_ = false;
  }
bool stor::DiskWriterResources::streamChangeOngoing ( ) [virtual]

Returns true when a stream configuration change is requested or in progress.

Definition at line 85 of file DiskWriterResources.cc.

References streamChangeInProgress_, streamChangeIsNeeded_, and streamChangeMutex_.

  {
    boost::mutex::scoped_lock sl(streamChangeMutex_);
    return (streamChangeIsNeeded_ || streamChangeInProgress_);
  }
bool stor::DiskWriterResources::streamChangeRequested ( bool &  doConfig,
EvtStrConfigListPtr evtStrConfig,
ErrStrConfigListPtr errStrConfig,
DiskWritingParams dwParams,
unsigned int &  runNumber,
boost::posix_time::time_duration &  timeoutValue 
)

Checks if a request has been made to change the stream configuration in the DiskWriter streams *and* clears any pending request. Existing streams are purged. If doConfig is true, the supplied new configurations, new run number, and dequeue timeout value should be used to configure a new set of DiskWriter streams.

Definition at line 45 of file DiskWriterResources.cc.

  {
    boost::mutex::scoped_lock sl(streamChangeMutex_);

    if (! streamChangeIsNeeded_) {return false;}

    streamChangeIsNeeded_ = false;

    doConfig = configurationIsNeeded_;
    if (configurationIsNeeded_)
    {
      configurationIsNeeded_ = false;
      evtStrConfig = requestedEventStreamConfig_;
      errStrConfig = requestedErrorStreamConfig_;
      dwParams = requestedDiskWritingParams_;
      runNumber = requestedRunNumber_;
      timeoutValue = requestedTimeout_;
    }

    streamChangeInProgress_ = true;

    return true;
  }
void stor::DiskWriterResources::waitForStreamChange ( ) [virtual]

Waits until a requested stream configuration change has been completed.

Definition at line 76 of file DiskWriterResources.cc.

References streamChangeCondition_, streamChangeInProgress_, streamChangeIsNeeded_, and streamChangeMutex_.

  {
    boost::mutex::scoped_lock sl(streamChangeMutex_);
    if (streamChangeIsNeeded_ || streamChangeInProgress_)
      {
        streamChangeCondition_.wait(sl);
      }
  }

Member Data Documentation

Definition at line 111 of file DiskWriterResources.h.

Referenced by requestStreamDestruction().

Definition at line 114 of file DiskWriterResources.h.

Referenced by isBusy(), and setBusy().

Definition at line 113 of file DiskWriterResources.h.

Definition at line 118 of file DiskWriterResources.h.

Definition at line 117 of file DiskWriterResources.h.

Definition at line 116 of file DiskWriterResources.h.

Definition at line 119 of file DiskWriterResources.h.

boost::posix_time::time_duration stor::DiskWriterResources::requestedTimeout_ [private]

Definition at line 120 of file DiskWriterResources.h.

Definition at line 123 of file DiskWriterResources.h.

Referenced by streamChangeDone(), and waitForStreamChange().