20 #ifndef __TPIE_PIPELINING_PIPELINE_H__
21 #define __TPIE_PIPELINING_PIPELINE_H__
27 #include <tpie/file_manager.h>
28 #include <unordered_set>
33 namespace pipelining {
65 void plot(std::ostream & out) {plot_impl(out,
false);}
77 void plot_full(std::ostream & out) {plot_impl(out,
true);}
86 bool can_fetch(std::string key);
90 node_map::ptr get_node_map()
const {
94 void output_memory(std::ostream & o)
const;
96 size_t uid()
const {
return m_uid;};
99 node_map::ptr m_nodeMap;
102 void plot_impl(std::ostream & out,
bool full);
116 memory_size_type filesAvailable, memory_size_type mem,
117 const char *
file,
const char *
function);
124 memory_size_type mem,
125 const char * file,
const char *
function) {
129 double memory()
const {
133 void order_before(pipeline_base & other);
143 template <
typename fact_t>
146 typedef typename fact_t::constructed_type gen_t;
149 this->m_memory = factory.memory();
151 auto n = std::unique_ptr<gen_t>(
new gen_t(factory.construct()));
152 this->m_nodeMap = n->get_node_map()->find_authority();
153 this->m_nodeMap->increment_pipeline_ref();
154 this->m_nodeMap->add_owned_node(std::move(n));
164 if (this->m_nodeMap) {
165 this->m_nodeMap->find_authority()->decrement_pipeline_ref();
173 extern std::unordered_set<bits::pipeline_base_base *> current_pipelines;
174 extern std::mutex current_pipelines_mutex;
190 template <
typename T>
192 *
this = std::move(from);
195 template <
typename T>
197 p.reset(
new T(std::move(from)));
201 pipeline(
const std::shared_ptr<bits::pipeline_base> & p): p(p) {}
209 const char *
file,
const char *
function) {
214 memory_size_type mem,
215 const char * file,
const char *
function) {
220 memory_size_type filesAvailable, memory_size_type mem,
221 const char * file,
const char *
function) {
222 (*p)(items, pi, filesAvailable, mem, file,
function);
225 void plot(std::ostream & os = std::cout) {
229 void plot_full(std::ostream & os = std::cout) {
233 inline double memory()
const {
237 bits::node_map::ptr get_node_map()
const {
238 return p->get_node_map();
241 bool can_fetch(std::string key) {
242 return p->can_fetch(key);
246 return p->fetch_any(key);
249 template <
typename T>
250 T & fetch(std::string key) {
252 return any_cast<T>(a);
256 p->forward_any(key, std::move(value));
259 template <
typename T>
260 void forward(std::string key, T value) {
265 p->order_before(*other.p);
269 void output_memory(std::ostream & o)
const {p->output_memory(o);}
271 std::shared_ptr<bits::pipeline_base> p;
278 #endif // __TPIE_PIPELINING_PIPELINE_H__
The base class for indicating the progress of some task.
Null-object progress indicator.
Central file abstraction.
void operator()(stream_size_type items, progress_indicator_base &pi, memory_size_type filesAvailable, memory_size_type mem, const char *file, const char *function)
Invoke the pipeline.
void plot(std::ostream &out)
Generate a GraphViz plot of the pipeline.
a dummy progress indicator that produces no output
Virtual superclass for pipelines and subpipelines.
memory_manager & get_memory_manager()
Return a reference to the memory manager.
file_manager & get_file_manager()
Return a reference to the file manager.
size_t available() const noexcept
Return the amount of the resource still available to be assigned.
void plot_full(std::ostream &out)
Generate a GraphViz plot of the actor graph.
Node factory for variadic argument generators.
This class is used to avoid writing the template argument in the pipeline_impl type.
void operator()(stream_size_type items, progress_indicator_base &pi, memory_size_type mem, const char *file, const char *function)
Invoke the pipeline with amount of available files automatically configured.
virtual ~pipeline_base_base()
Virtual dtor.