Functions
_test_pipeline.cxx File Reference
#include "WireCellUtil/Testing.h"
#include <boost/pipeline.hpp>
#include <iostream>

Go to the source code of this file.

Functions

void test_queue ()
 
void consume1 (int x)
 
void consume2 (queue_front< int > &qf)
 
int consume3 (int x)
 
int consume4 (queue_front< int > &qf)
 
void test_to ()
 
void test_tofunction ()
 
int main ()
 

Function Documentation

void consume1 ( int  x)

Definition at line 41 of file _test_pipeline.cxx.

41  {
42  cerr << "consume1(" << x << ")" << endl;
43 }
list x
Definition: train.py:276
QTextStream & endl(QTextStream &s)
void consume2 ( queue_front< int > &  qf)

Definition at line 44 of file _test_pipeline.cxx.

44  {
45  int i; qf.wait_pull(i);
46  cerr << "consume2(" << i << ")" << endl;
47 }
QTextStream & endl(QTextStream &s)
int consume3 ( int  x)

Definition at line 48 of file _test_pipeline.cxx.

48  { return 0;
49  cerr << "consume3(" << x << ")" << endl;
50 }
list x
Definition: train.py:276
QTextStream & endl(QTextStream &s)
int consume4 ( queue_front< int > &  qf)

Definition at line 51 of file _test_pipeline.cxx.

51  {
52  int i; qf.wait_pull(i);
53  cerr << "consume4(" << i << ")" << endl;
54  return 0;
55 }
QTextStream & endl(QTextStream &s)
int main ( void  )

Definition at line 98 of file _test_pipeline.cxx.

99 {
100  test_queue();
101  test_to();
102  test_tofunction();
103 
104 
105  return 0;
106 }
void test_queue()
void test_to()
void test_tofunction()
void test_queue ( )

Definition at line 9 of file _test_pipeline.cxx.

10 {
11  queue<int> q;
12  queue_front<int> qf(q);
13  queue_back<int> qb(q);
14 
15  Assert(qf.is_closed() == false);
16 
17  qb.push(1);
18  qb.push(2);
19  qb.push(3);
20 
21  int input = 0;
22 
23  qf.wait_pull(input);
24  Assert(input == 1);
25 
26  qf.wait_pull(input);
27  Assert(input == 2);
28 
29  qb.close();
30 
31  qf.wait_pull(input);
32  Assert(input == 3);
33 
34  Assert(qf.is_closed());
35 }
#define Assert
Definition: Testing.h:7
static int input(void)
Definition: code.cpp:15695
void test_to ( )

Definition at line 58 of file _test_pipeline.cxx.

59 {
60  std::vector<int> input{0, 1, 2, 3};
61 
62  thread_pool pool(4);
63 
64  auto exec1 = (from(input) | consume1).run(pool);
65  auto exec2 = (from(input) | consume2).run(pool);
66  auto exec3 = (from(input) | to(consume3)).run(pool);
67  auto exec4 = (from(input) | to(consume4)).run(pool);
68 
69  exec1.wait();
70  exec2.wait();
71  exec3.wait();
72  exec4.wait();
73 }
int consume3(int x)
void consume1(int x)
std::shared_ptr< spdlog::details::thread_pool > thread_pool()
Definition: async.h:83
static int input(void)
Definition: code.cpp:15695
void consume2(queue_front< int > &qf)
int consume4(queue_front< int > &qf)
unsigned int run
void test_tofunction ( )

Definition at line 75 of file _test_pipeline.cxx.

76 {
77  auto f_consume1 = std::function<void(int)>(consume1);
78  auto f_consume2 = std::function<void(queue_front<int>&)>(consume2);
79  auto f_consume3 = std::function<int(int)>(consume3);
80  auto f_consume4 = std::function<int(queue_front<int>&)>(consume4);
81 
82  std::vector<int> input{0, 1, 2, 3};
83 
84  thread_pool pool(4);
85 
86  auto exec1 = (from(input) | f_consume1).run(pool);
87  auto exec2 = (from(input) | f_consume2).run(pool);
88  auto exec3 = (from(input) | to(f_consume3)).run(pool);
89  auto exec4 = (from(input) | to(f_consume4)).run(pool);
90 
91  exec1.wait();
92  exec2.wait();
93  exec3.wait();
94  exec4.wait();
95 
96 }
int consume3(int x)
void consume1(int x)
std::shared_ptr< spdlog::details::thread_pool > thread_pool()
Definition: async.h:83
static int input(void)
Definition: code.cpp:15695
void consume2(queue_front< int > &qf)
int consume4(queue_front< int > &qf)
unsigned int run