27 #ifndef NIDAS_CORE_SAMPLEBUFFER_H
28 #define NIDAS_CORE_SAMPLEBUFFER_H
36 namespace nidas {
namespace core {
144 void flush() throw();
257 int run() throw(nidas::util::Exception);
261 std::deque<const Sample*> _sampleBuf;
void setKeepStats(bool val)
Definition: SampleBuffer.h:54
std::vector< const Sample * > * _inserterBuf
Definition: SampleBuffer.h:265
void setKeepStats(bool val)
Definition: SampleSourceSupport.h:154
size_t _heapMax
Limit on the maximum size of memory to use while buffering samples.
Definition: SampleBuffer.h:287
void addSampleClientForTag(SampleClient *client, const SampleTag *tag)
Add a Client for a given SampleTag.
Definition: SampleBuffer.h:121
SampleBuffer & operator=(const SampleBuffer &)
No assignment.
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition: SampleBuffer.h:112
size_t _discardedSamples
Number of samples discarded because of _heapSize > _heapMax and heapBlock == true.
Definition: SampleBuffer.h:313
void removeSampleClientForTag(SampleClient *client, const SampleTag *tag)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition: SampleBuffer.h:126
void setHeapBlock(bool val)
Definition: SampleBuffer.h:204
void setRealTime(bool val)
Is this sorter running in real-time? If so then we can screen for bad time-tags by checking against t...
Definition: SampleBuffer.h:233
Interface for a Thread for buffering samples.
Definition: SampleThread.h:52
float getLengthSecs() const
Definition: SampleBuffer.h:179
bool getRealTime() const
Definition: SampleBuffer.h:238
SampleSourceSupport _source
Definition: SampleBuffer.h:270
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleBuffer.h:69
void removeSampleTag(const SampleTag *tag)
Definition: SampleSourceSupport.cc:67
size_t sizeNoLock() const
Definition: SampleBuffer.cc:91
int _discardWarningCount
How often to log warnings about discardedSamples.
Definition: SampleBuffer.h:324
bool _doFlush
Definition: SampleBuffer.h:326
std::list< const SampleTag * > getSampleTags() const
Implementation of SampleSource::getSampleTags().
Definition: SampleBuffer.h:91
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
SampleTagIterator getSampleTagIterator() const
Definition: SampleSourceSupport.cc:75
void removeSampleTag(const SampleTag *tag)
Definition: SampleBuffer.h:83
nidas::util::Cond _heapCond
Definition: SampleBuffer.h:307
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition: SampleBuffer.h:107
A source of samples.
Definition: SampleSourceSupport.h:47
void heapDecrement(size_t bytes)
Utility function to decrement the heap size after writing one or more samples.
Definition: SampleBuffer.cc:399
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition: SampleSourceSupport.cc:88
bool getKeepStats() const
Definition: SampleSourceSupport.h:159
bool _realTime
Is this sorter running in real-time? If so then we can screen for bad time-tags by checking against t...
Definition: SampleBuffer.h:335
size_t getHeapMax() const
Definition: SampleBuffer.h:190
bool getHeapBlock() const
Definition: SampleBuffer.h:206
void removeSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:121
void setHeapMax(size_t val)
Set the maximum amount of heap memory to use for sorting samples.
Definition: SampleBuffer.h:188
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:80
Pure virtual interface of a client of Samples.
Definition: SampleClient.h:38
size_t getNumFutureSamples() const
Number of samples discarded because their timetags were in the future.
Definition: SampleBuffer.h:223
size_t size() const
Current number of samples in the buffer.
Definition: SampleBuffer.cc:85
size_t getHeapSize() const
Get the current amount of heap being used for sorting.
Definition: SampleBuffer.h:195
virtual ~SampleBuffer()
Definition: SampleBuffer.cc:67
const SampleStats & getSampleStats() const
Definition: SampleSourceSupport.h:149
std::vector< const Sample * > * _consumerBuf
Definition: SampleBuffer.h:267
std::vector< const Sample * > _sampleBufs[2]
Definition: SampleBuffer.h:263
void addSampleTag(const SampleTag *tag)
How to tell this SampleBuffer what sample tags it will be sorting.
Definition: SampleBuffer.h:78
nidas::util::Cond _flushCond
Definition: SampleBuffer.h:281
SampleBuffer(const std::string &name, bool raw)
Constructor.
Definition: SampleBuffer.cc:43
void setLateSampleCacheSize(unsigned int)
Definition: SampleBuffer.h:243
A SampleClient that buffers its received samples, using a pair of STL vectors, and then sends the buf...
Definition: SampleBuffer.h:43
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition: SampleBuffer.h:99
bool _heapBlock
_heapBlock controls what happens when the number of bytes in _samples exceeds _heapMax.
Definition: SampleBuffer.h:305
Interface to a data sample.
Definition: Sample.h:189
int run()
Thread run function.
Definition: SampleBuffer.cc:112
bool emptyNoLock() const
Definition: SampleBuffer.cc:100
void setLengthSecs(float)
Definition: SampleBuffer.h:175
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleBuffer.h:131
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:60
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
bool _flushed
Definition: SampleBuffer.h:328
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:101
size_t _heapSize
Current heap size, in bytes.
Definition: SampleBuffer.h:292
A source of samples.
Definition: SampleStats.h:41
size_t getNumDiscardedSamples() const
Number of samples discarded because of _heapSize > _heapMax and heapBlock == true.
Definition: SampleBuffer.h:214
A wrapper class for a Posix condition variable.
Definition: ThreadSupport.h:245
const SampleStats & getSampleStats() const
Definition: SampleBuffer.h:136
void interrupt()
Interrupt this thread.
Definition: SampleBuffer.cc:374
bool receive(const Sample *s)
Insert a sample in the buffer, where it is then passed on to SampleClients.
Definition: SampleBuffer.cc:534
void flush()
flush all samples from buffer, distributing them to SampleClients.
Definition: SampleBuffer.cc:548
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleSourceSupport.cc:136
size_t _realTimeFutureSamples
Number of samples discarded because getRealTime() is true and the samples have timetags later than th...
Definition: SampleBuffer.h:319
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition: SampleSourceSupport.cc:54
bool getKeepStats() const
Definition: SampleBuffer.h:59
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:66
unsigned int getLateSampleCacheSize() const
Definition: SampleBuffer.h:247
nidas::util::Cond _sampleBufCond
Definition: SampleBuffer.h:279
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition: SampleSourceSupport.cc:60
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleBuffer.h:64