TPIE

v1.1rc1-6-g0c97303
tpie::pipelining::parallel_bits::state< T1, T2 > Class Template Reference

State subclass containing the item type specific state, i.e. More...

#include <tpie/pipelining/parallel/base.h>

Inherits tpie::pipelining::parallel_bits::state_base.

Public Types

typedef boost::shared_ptr< stateptr
 
typedef state_base::mutex_t mutex_t
 
typedef state_base::cond_t cond_t
 
typedef state_base::lock_t lock_t
 

Public Member Functions

template<typename fact_t >
 state (const options opts, const fact_t &fact)
 
void set_consumer_ptr (consumer< T2 > *cons)
 
consumer< T2 > *const * get_consumer_ptr_ptr () const
 
void set_input_ptr (size_t idx, node *v)
 Must not be used concurrently. More...
 
void set_output_ptr (size_t idx, after_base *v)
 Must not be used concurrently. More...
 
nodeinput (size_t idx)
 Get the specified before instance. More...
 
after_baseoutput (size_t idx)
 Get the specified after instance. More...
 
worker_state get_state (size_t idx)
 Shared state, must have mutex to use. More...
 
void transition_state (size_t idx, worker_state from, worker_state to)
 Shared state, must have mutex to use. More...
 

Public Attributes

array< parallel_input_buffer
< T1 > * > 
m_inputBuffers
 
array< parallel_output_buffer
< T2 > * > 
m_outputBuffers
 
consumer< T2 > * m_cons
 
std::auto_ptr< threads< T1, T2 > > pipes
 
const options opts
 
mutex_t mutex
 Single mutex. More...
 
cond_t producerCond
 Condition variable. More...
 
cond_t * workerCond
 Condition variable, one per worker. More...
 
size_t runningWorkers
 Shared state, must have mutex to write. More...
 

Protected Attributes

std::vector< node * > m_inputs
 
std::vector< after_base * > m_outputs
 
std::vector< worker_state > m_states
 

Detailed Description

template<typename T1, typename T2>
class tpie::pipelining::parallel_bits::state< T1, T2 >

State subclass containing the item type specific state, i.e.

the input/output buffers and the concrete pipes.

Definition at line 44 of file base.h.

Member Function Documentation

worker_state tpie::pipelining::parallel_bits::state_base::get_state ( size_t  idx)
inlineinherited

Shared state, must have mutex to use.

Definition at line 268 of file base.h.

268  {
269  return m_states[idx];
270  }
node& tpie::pipelining::parallel_bits::state_base::input ( size_t  idx)
inlineinherited

Get the specified before instance.

Enables easy construction of the pipeline graph at runtime.

Shared state, must have mutex to use.

Definition at line 253 of file base.h.

253 { return *m_inputs[idx]; }
after_base& tpie::pipelining::parallel_bits::state_base::output ( size_t  idx)
inlineinherited

Get the specified after instance.

Serves two purposes: First, it enables easy construction of the pipeline graph at runtime. Second, it is used by before to send batch signals to after.

Shared state, must have mutex to use.

Definition at line 265 of file base.h.

265 { return *m_outputs[idx]; }
void tpie::pipelining::parallel_bits::state_base::set_input_ptr ( size_t  idx,
node v 
)
inlineinherited

Must not be used concurrently.

Definition at line 237 of file base.h.

237  {
238  m_inputs[idx] = v;
239  }
void tpie::pipelining::parallel_bits::state_base::set_output_ptr ( size_t  idx,
after_base v 
)
inlineinherited

Must not be used concurrently.

Definition at line 242 of file base.h.

242  {
243  m_outputs[idx] = v;
244  }
void tpie::pipelining::parallel_bits::state_base::transition_state ( size_t  idx,
worker_state  from,
worker_state  to 
)
inlineinherited

Shared state, must have mutex to use.

Definition at line 273 of file base.h.

References tpie::log_error().

273  {
274  if (m_states[idx] != from) {
275  std::stringstream ss;
276  ss << idx << " Invalid state transition " << from << " -> " << to << "; current state is " << m_states[idx];
277  log_error() << ss.str() << std::endl;
278  throw exception(ss.str());
279  }
280  m_states[idx] = to;
281  }
logstream & log_error()
Return logstream for writing error log messages.
Definition: tpie_log.h:104

Member Data Documentation

mutex_t tpie::pipelining::parallel_bits::state_base::mutex
inherited

Single mutex.

Definition at line 212 of file base.h.

cond_t tpie::pipelining::parallel_bits::state_base::producerCond
inherited

Condition variable.

Who waits: The producer, with the single mutex (waits until at least one worker has state = IDLE or state = OUTPUTTING).

Who signals: The par_after, when a worker is OUTPUTTING.

Definition at line 220 of file base.h.

size_t tpie::pipelining::parallel_bits::state_base::runningWorkers
inherited

Shared state, must have mutex to write.

Definition at line 234 of file base.h.

cond_t* tpie::pipelining::parallel_bits::state_base::workerCond
inherited

Condition variable, one per worker.

Who waits: The worker's par_before when waiting for input (wait for state = PROCESSING), the worker's par_after when waiting for output to be read (wait for state = IDLE). Waits with the single mutex.

Who signals: par_producer, when input has been written (sets state to PROCESSING). par_consumer, when output has been read (sets state to IDLE).

Definition at line 231 of file base.h.


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