An extension of dsp::RingBuffer to allow any class to run in a separate thread Be wary of use in save_data context + CombineThread context Be wary of changing input/output of the Operation mid-run HSK 17 January 2005. More...

#include <Simultaneous.h>

Inheritance diagram for dsp::Simultaneous:
dsp::Operation OwnStream Reference::Able Reference::HeapTracked

Public Member Functions

 Simultaneous ()
 Null constructor.
 
virtual ~Simultaneous ()
 Virtual destructor.
 
Operationget_op ()
 Retrieve a pointer to the Operation.
 
bool has_op ()
 Inquire whether an Operation is being stored.
 
void set_op (Operation *_op)
 Set the Operation.
 
template<class T >
T * get ()
 Convenience method to return the Operation.
 
void stop_thread ()
 Prompts the thread to exit.
 
- Public Member Functions inherited from dsp::Operation
 Operation (const char *name)
 All sub-classes must specify a unique name. More...
 
 Operation (const Operation &)
 Copy constructor.
 
virtual ~Operation ()
 Virtual destructor.
 
virtual bool operate ()
 Call this method to operate on data Returns false on failure. More...
 
virtual void prepare ()
 Prepare for data operations. More...
 
virtual void reserve ()
 Reserve the maximum amount of memory required. More...
 
virtual void add_extensions (Extensions *)
 Add any extensions.
 
virtual void combine (const Operation *)
 Combine accumulated results with another operation. More...
 
virtual void report () const
 Report operation statistics.
 
virtual void reset ()
 Reset accumulated results to intial values. More...
 
std::string get_name () const
 Return the unique name of this operation.
 
double get_total_time () const
 Return the total time spent on this Operation in seconds.
 
double get_elapsed_time () const
 Get the time spent in the last invocation of operate()
 
virtual uint64_t get_total_weights () const
 Return the total number of timesample weights encountered. More...
 
virtual uint64_t get_discarded_weights () const
 Return the number of invalid timesample weights encountered.
 
int get_id ()
 Inquire the unique instantiation id.
 
virtual Function get_function () const
 Get the function classification of this operation.
 
virtual double get_delay_time () const
 Get the time delay of this operation, if any, in seconds.
 
virtual void set_scratch (Scratch *)
 Set the scratch space.
 
bool scratch_was_set () const
 
virtual uint64_t bytes_storage () const
 The number of bytes of additional storage used by the operation.
 
virtual uint64_t bytes_scratch () const
 The number of bytes of scratch space used by the operation. More...
 
- Public Member Functions inherited from OwnStream
 OwnStream (const OwnStream &)
 
const OwnStreamoperator= (const OwnStream &)
 
virtual void set_cout (std::ostream &) const
 
virtual void set_cerr (std::ostream &) const
 
- Public Member Functions inherited from Reference::Able
 Able (const Able &)
 
Ableoperator= (const Able &)
 
unsigned get_reference_count () const
 
- Public Member Functions inherited from Reference::HeapTracked
 HeapTracked (const HeapTracked &)
 
HeapTrackedoperator= (const HeapTracked &)
 
bool __is_on_heap () const
 

Public Attributes

TimeSerieslast_on
 

Protected Member Functions

virtual void operation ()
 Does the work.
 
bool new_data ()
 Puts the new input data into the input ringbuffer and puts the output data processed in the extra thread into the output so that it's ready to be processed by the next Operation (If necessary)
 
bool copy_input_into_ringbuffer ()
 Copies the new input data into the input ringbuffer if necessary.
 
bool copy_ringbuffer_into_output ()
 Puts the output data processed in the extra thread into the output so that it's ready to be processed by the next Operation (If necessary)
 
void start_thread ()
 Spawns the extra thread if using threads.
 
void destroy_thread ()
 Destroys the extra thread.
 
void wait_to_synch ()
 Makes the thread wait for the call to operate() before running.
 
bool can_run ()
 Returns whether or not the user has said to stop.
 
void checks ()
 Checks stuff before operate()
 
void run_op ()
 Calls op->operate() after setting up the input/output buffers.
 
bool op_uses_an_input ()
 Returns true if the Operation needs an input to be set.
 
bool op_uses_an_output ()
 Returns true if the Operation needs an output to be set.
 
void setup_buffers ()
 Makes sure the buffers point to something sane.
 
template<class T >
bool newify_buffers (vector< Reference::To< BasicBuffer > > &buffers)
 Worker function that actually calls 'new' for each element in the vector.
 
bool newify_input_buffers ()
 Tries to work out what sort of buffers the input_buffers should be.
 
bool newify_output_buffers ()
 Tries to work out what sort of buffers the input_buffers should be.
 
bool newify_those_buffers (string typestring, vector< Reference::To< BasicBuffer > > &buffers)
 Worker function for newify_input_buffers() and newify_output_buffers()
 
Reference::To< BasicBuffer > setup_op_output ()
 Gives the Operation an output if it needs one.
 
Reference::To< BasicBuffer > setup_op_input ()
 Gives the Operation an input if it needs one.
 
string get_input_typestring ()
 Returns a string describing the input type.
 
string get_output_typestring ()
 Returns a string describing the output type.
 
void initialise_op_input ()
 Initialises the 'op_input' variable.
 
void initialise_op_output ()
 Initialises the 'op_output' variable.
 
Reference::To< BasicBuffer > new_buffer (string typestring)
 Returns a new Buffer of the requisite type.
 
Reference::To< BasicBuffer > pop_free_input_buffer ()
 pops a free/full input/output buffer as soon as one is available
 
Reference::To< BasicBuffer > pop_full_input_buffer ()
 
Reference::To< BasicBuffer > pop_free_output_buffer ()
 
Reference::To< BasicBuffer > pop_full_output_buffer ()
 
void wait_for_free_input_buffer ()
 Waits around until a free/full input/output buffer is available.
 
void wait_for_full_input_buffer ()
 
void wait_for_free_output_buffer ()
 
void wait_for_full_output_buffer ()
 
void init ()
 Called by constructor to initialise stuff.
 
- Protected Member Functions inherited from dsp::Operation
virtual bool can_operate ()
 Return false if the operation doesn't have enough data to proceed.
 
virtual void set_name (const std::string &_name)
 Set the name!
 
int timers_index (const std::string &op_name)
 Returns the index in the 'timers' array of a particular timer.
 
- Protected Member Functions inherited from Reference::Able
Handle__reference (bool active) const
 
void __dereference (bool auto_delete=true) const
 

Static Protected Member Functions

static void * op_loop (Simultaneous *thiz)
 This function runs in the extra thread.
 

Protected Attributes

Reference::To< Operationop
 The class being run simultaneously.
 
bool thread_running
 True if the thread has been started up.
 
vector< Reference::To< BasicBuffer > > input_buffers
 Buffers for storing data

 
vector< Reference::To< BasicBuffer > > output_buffers
 
std::queue< Reference::To< BasicBuffer > > free_input_buffers
 Ordered list of who is to be used next.
 
std::queue< Reference::To< BasicBuffer > > full_input_buffers
 
std::queue< Reference::To< BasicBuffer > > free_output_buffers
 
std::queue< Reference::To< BasicBuffer > > full_output_buffers
 
Reference::To< BasicBuffer > op_input
 Has the actual Buffers that the Operation was originally set up with.
 
Reference::To< BasicBuffer > op_output
 
pthread_mutex_t free_input_buffers_mutex
 Mutexes and conds.
 
pthread_mutex_t full_input_buffers_mutex
 
pthread_mutex_t free_output_buffers_mutex
 
pthread_mutex_t full_output_buffers_mutex
 
pthread_mutex_t free_input_mutex
 
pthread_mutex_t full_input_mutex
 
pthread_mutex_t free_output_mutex
 
pthread_mutex_t full_output_mutex
 
pthread_cond_t free_input_cond
 
pthread_cond_t full_input_cond
 
pthread_cond_t free_output_cond
 
pthread_cond_t full_output_cond
 
pthread_mutex_t synch_mutex
 
pthread_cond_t synch_cond
 
pthread_mutex_t running_mutex
 
pthread_cond_t running_cond
 
float wait_time
 Time-out time on call to pthread_cond_wait (in seconds) [1.0].
 
bool use_threads
 Whether to use threads [true].
 
pthread_t * op_thread
 The thread object.
 
bool keep_running
 Whether the user wants to finish up or keep running [true].
 
bool synch
 Whether to synchronise work with the main thread [false].
 
- Protected Attributes inherited from dsp::Operation
Scratchscratch
 Shared scratch space, if needed.
 
bool set_scratch_called
 
std::string name
 Operation name.
 
uint64_t discarded_weights
 Number of time sample weights encountered that are flagged invalid.
 
uint64_t total_weights
 Total number of time sample weights encountered.
 
RealTimer optime
 Stop watch records the amount of time spent performing this operation.
 
int id
 Unique instantiation id.
 
bool prepared
 Set true when preparation optimizations are completed.
 

Additional Inherited Members

- Public Types inherited from dsp::Operation
enum  Function { Producer, Procedural, Structural }
 The function of the operator. More...
 
- Static Public Member Functions inherited from Reference::Able
static size_t get_instance_count ()
 
- Static Public Member Functions inherited from Reference::HeapTracked
static void * operator new (size_t size, void *ptr=0)
 
static void operator delete (void *location, void *ptr)
 
static void operator delete (void *location)
 
static size_t get_heap_queue_size ()
 
- Static Public Attributes inherited from dsp::Operation
static bool record_time = false
 Global flag enables stopwatch to record the time spent operating. More...
 
static bool report_time = true
 Global flag enables report of time spent in operation on descruction. More...
 
static bool verbose = false
 Global verbosity flag.
 
static int operation_status = 0
 Operations can set this to non-zero in operation() if they fail.
 
static bool check_state = true
 Operations should perform internal consistency checks.
 
static int instantiation_count = 0
 Counts how many Operation instantiations there have been Used for setting the unique instantiation ID. More...
 

Detailed Description

An extension of dsp::RingBuffer to allow any class to run in a separate thread Be wary of use in save_data context + CombineThread context Be wary of changing input/output of the Operation mid-run HSK 17 January 2005.


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

Generated using doxygen 1.8.17