File src/factory.h changed (mode: 100644) (index a1a090b..893c5f4) |
2 |
2 |
|
|
3 |
3 |
#include "impl/batch.h" |
#include "impl/batch.h" |
4 |
4 |
|
|
|
5 |
|
#include <lib/circuit/src/impl/queue.h> |
|
6 |
|
#include <lib/circuit/src/impl/stack.h> |
|
7 |
|
|
5 |
8 |
namespace om636 { |
namespace om636 { |
6 |
9 |
|
|
7 |
10 |
namespace control { |
namespace control { |
8 |
11 |
template <typename... T> |
template <typename... T> |
9 |
|
std::shared_ptr<BatchImpl<dummy, T...>> make_batch() |
|
|
12 |
|
std::shared_ptr<BatchImpl<QueuePolicy, T...>> make_batch() |
10 |
13 |
{ |
{ |
11 |
|
return std::make_shared<BatchImpl<dummy, T...>>(); |
|
|
14 |
|
return std::make_shared<BatchImpl<QueuePolicy, T...>>(); |
12 |
15 |
} |
} |
13 |
16 |
|
|
14 |
17 |
} |
} |
File src/impl/batch.h changed (mode: 100644) (index 887da68..ffc78e6) |
4 |
4 |
#include <memory> |
#include <memory> |
5 |
5 |
#include <vector> |
#include <vector> |
6 |
6 |
|
|
7 |
|
#include <lib/circuit/src/index.h> |
|
|
7 |
|
#include <lib/circuit/src/impl/circuit_host.h> |
8 |
8 |
|
|
9 |
9 |
#include "../interface.h" |
#include "../interface.h" |
10 |
10 |
|
|
11 |
11 |
namespace om636 { |
namespace om636 { |
12 |
12 |
namespace control { |
namespace control { |
13 |
13 |
|
|
14 |
|
template<class T> |
|
15 |
|
class dummy |
|
16 |
|
{}; |
|
17 |
|
|
|
18 |
|
|
|
19 |
14 |
template <template<typename> typename P, typename... T> |
template <template<typename> typename P, typename... T> |
20 |
15 |
class BatchImpl : public Batch<T...> { |
class BatchImpl : public Batch<T...> { |
21 |
16 |
public: |
public: |
|
... |
... |
namespace control { |
30 |
25 |
|
|
31 |
26 |
typedef std::weak_ptr<typename agent_type::element_type> pointer_type; |
typedef std::weak_ptr<typename agent_type::element_type> pointer_type; |
32 |
27 |
typedef std::tuple<pointer_type, bool> tuple_type; |
typedef std::tuple<pointer_type, bool> tuple_type; |
33 |
|
typedef circuit::CircuitQueue<tuple_type> batch_type; |
|
|
28 |
|
typedef circuit::CircuitHost<tuple_type, P> batch_type; |
34 |
29 |
batch_type& impl_ref(); |
batch_type& impl_ref(); |
35 |
30 |
const batch_type& impl_ref() const; |
const batch_type& impl_ref() const; |
36 |
31 |
|
|
File test/src/batch.h changed (mode: 100644) (index f5ac19c..47cff77) |
1 |
|
using namespace om636; |
|
|
1 |
|
#include <lib/circuit/src/impl/queue.h> |
|
2 |
|
|
2 |
3 |
using namespace om636::control; |
using namespace om636::control; |
|
4 |
|
using namespace om636; |
3 |
5 |
using namespace std; |
using namespace std; |
|
6 |
|
using namespace om636::circuit; |
4 |
7 |
|
|
5 |
8 |
void check_unhook_while_traverse() |
void check_unhook_while_traverse() |
6 |
9 |
{ |
{ |
7 |
|
BatchImpl<dummy> batch; |
|
|
10 |
|
BatchImpl<QueuePolicy> batch; |
8 |
11 |
unsigned passed(0); |
unsigned passed(0); |
9 |
12 |
|
|
10 |
|
typename BatchImpl<dummy>::listener_type temp(batch.hook([&]() { |
|
|
13 |
|
typename BatchImpl<QueuePolicy>::listener_type temp(batch.hook([&]() { |
11 |
14 |
++passed; |
++passed; |
12 |
15 |
temp.reset(); |
temp.reset(); |
13 |
16 |
})); |
})); |
|
... |
... |
void check_unhook_while_traverse() |
21 |
24 |
|
|
22 |
25 |
void dead_agent_removal() |
void dead_agent_removal() |
23 |
26 |
{ |
{ |
24 |
|
typedef BatchImpl<dummy, int> batch_type; |
|
|
27 |
|
typedef BatchImpl<QueuePolicy, int> batch_type; |
25 |
28 |
batch_type batch; |
batch_type batch; |
26 |
29 |
batch.hook([](int) {}); |
batch.hook([](int) {}); |
27 |
30 |
batch.invoke(9); |
batch.invoke(9); |
|
... |
... |
void dead_agent_removal() |
31 |
34 |
|
|
32 |
35 |
void check_traverse_with_arg() |
void check_traverse_with_arg() |
33 |
36 |
{ |
{ |
34 |
|
BatchImpl<dummy, int> batch; |
|
|
37 |
|
BatchImpl<QueuePolicy, int> batch; |
35 |
38 |
int v = 0; |
int v = 0; |
36 |
39 |
auto p(batch.hook([&](int i) { |
auto p(batch.hook([&](int i) { |
37 |
40 |
v = i; |
v = i; |
|
... |
... |
void check_traverse_with_arg() |
44 |
47 |
|
|
45 |
48 |
void check_traverse_with_args() |
void check_traverse_with_args() |
46 |
49 |
{ |
{ |
47 |
|
typedef BatchImpl<dummy, int, int> batch_type; |
|
|
50 |
|
typedef BatchImpl<QueuePolicy, int, int> batch_type; |
48 |
51 |
|
|
49 |
52 |
unsigned test_passed(0); |
unsigned test_passed(0); |
50 |
53 |
batch_type batch; |
batch_type batch; |
|
... |
... |
void check_traverse_with_args() |
62 |
65 |
|
|
63 |
66 |
void check_traverse_while_traverse() |
void check_traverse_while_traverse() |
64 |
67 |
{ |
{ |
65 |
|
BatchImpl<dummy> batch; |
|
|
68 |
|
BatchImpl<QueuePolicy> batch; |
66 |
69 |
unsigned passed(0); |
unsigned passed(0); |
67 |
70 |
|
|
68 |
71 |
auto p(batch.hook([&]() { |
auto p(batch.hook([&]() { |
|
... |
... |
void check_traverse_while_traverse() |
77 |
80 |
|
|
78 |
81 |
void check_traverse() |
void check_traverse() |
79 |
82 |
{ |
{ |
80 |
|
BatchImpl<dummy> batch; |
|
|
83 |
|
BatchImpl<QueuePolicy> batch; |
81 |
84 |
unsigned passed(0); |
unsigned passed(0); |
82 |
85 |
|
|
83 |
86 |
auto temp(batch.hook([&]() { |
auto temp(batch.hook([&]() { |