MultiThread.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2011 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/General/dsp/MultiThread.h
10 
11 #ifndef __dspsr_MultiThread_h
12 #define __dspsr_MultiThread_h
13 
14 #include "dsp/SingleThread.h"
15 
16 class ThreadContext;
17 
18 namespace dsp {
19 
21  class MultiThread : public Pipeline
22  {
23 
24  public:
25 
27  MultiThread ();
28 
30  ~MultiThread ();
31 
33  void set_nthread (unsigned);
34 
37 
39  void set_source (Source*);
40 
42  Source* get_source ();
43 
45  void construct ();
46 
48  void prepare ();
49 
51  virtual void share ();
52 
54  void run ();
55 
57  void finish ();
58 
60  uint64_t get_minimum_samples () const;
61 
62  protected:
63 
65 
67 
70 
73 
75  virtual SingleThread* new_thread () = 0;
76 
78  std::vector< Reference::To<SingleThread> > threads;
79 
82 
84  std::vector<pthread_t> ids;
85 
86  static void* thread (void*);
87 
88  void launch_threads ();
89 
90  static void wait (SingleThread* fold, SingleThread::State st);
91  static void signal (SingleThread* fold, SingleThread::State st);
92 
93  };
94 
95 }
96 
97 #endif // !defined(__MultiThread_h)
98 
99 
100 
101 
102 
void prepare()
Prepare the signal processing pipeline.
Definition: SingleThread.C:316
Error error
Error status.
Definition: SingleThread.h:135
Reference::To< Source > source
Source of data.
Definition: MultiThread.h:66
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
virtual void share(Source *)=0
Share any resources that can/should be shared between threads.
virtual void combine(const SingleThread *)
Combine the results from another processing thread.
Definition: SingleThread.C:678
State
Processing thread states.
Definition: SingleThread.h:118
Reference::To< SingleThread::Config > configuration
The shared thread configuration.
Definition: MultiThread.h:81
void set_source(Source *)
Set the Input from which data are read.
Definition: MultiThread.C:68
Per-thread configuration options.
Definition: SingleThread.h:185
Multiple pipeline threads.
Definition: MultiThread.h:21
ThreadContext * source_context
Thread lock for Input::load.
Definition: MultiThread.h:69
Source * get_source()
Get the Input from which data are read.
Definition: MultiThread.C:103
void prepare()
Prepare to fold the input TimeSeries.
Definition: MultiThread.C:127
~MultiThread()
Destructor.
Definition: MultiThread.C:33
Buffers the Transformation input.
Definition: InputBuffering.h:26
void take_ostream(std::ostream *newlog)
Take and manage a new ostream instance.
Definition: SingleThread.C:83
void construct()
Build the signal processing pipeline.
Definition: SingleThread.C:230
ThreadContext * state_changes
Condition for processing thread state changes.
Definition: MultiThread.h:72
Abstract base class of data reduction pipelines.
Definition: Pipeline.h:28
void set_configuration(SingleThread::Config *)
Set the configuration to be used by each thread.
Definition: MultiThread.C:59
void construct()
Build the signal processing pipeline.
Definition: MultiThread.C:109
void set_nthread(unsigned)
Set the number of thread to be used.
Definition: MultiThread.C:40
virtual SingleThread * new_thread()=0
The creator of new SingleThread threads.
virtual void share(SingleThread *)
Share any necessary resources with the specified thread.
Definition: SingleThread.C:175
SingleThread * colleague
Processing thread with whom sharing will occur.
Definition: SingleThread.h:144
ThreadContext * state_change
State change communication.
Definition: SingleThread.h:138
static ThreadContext * context
std::vector< Reference::To< SingleThread > > threads
The pipeline threads.
Definition: MultiThread.h:78
uint64_t get_minimum_samples() const
Get the minimum number of samples required to process.
Definition: MultiThread.C:174
MultiThread()
Constructor.
Definition: MultiThread.C:23
State state
Processing state.
Definition: SingleThread.h:132
void finish()
Finish everything.
Definition: SingleThread.C:751
virtual void set_context(ThreadContext *context)=0
Set the mutual exclusion and condition used to protect shared resources.
const std::string get_message() const
std::ostream * log
Pointer to the ostream.
Definition: SingleThread.h:115
A single Pipeline thread.
Definition: SingleThread.h:32
virtual void share()
Set up any resources that must be shared.
Definition: MultiThread.C:139
void run()
Run through the data.
Definition: SingleThread.C:546
Abstract interface to sources of TimeSeries data.
Definition: Source.h:22
void finish()
Finish everything.
Definition: MultiThread.C:298
Buffers the Transformation input.
Definition: InputBufferingShare.h:19
std::vector< pthread_t > ids
The thread ids.
Definition: MultiThread.h:84
virtual Source * clone() const =0
Return a default constructed clone of self.
void run()
Run through the data.
Definition: MultiThread.C:254

Generated using doxygen 1.8.17