File src/impl/batch.h changed (mode: 100644) (index 986d903..45643a7) |
... |
... |
namespace control { |
25 |
25 |
typedef std::weak_ptr<typename agent_type::element_type> pointer_type; |
typedef std::weak_ptr<typename agent_type::element_type> pointer_type; |
26 |
26 |
typedef std::tuple<pointer_type, bool> tuple_type; |
typedef std::tuple<pointer_type, bool> tuple_type; |
27 |
27 |
typedef circuit::CircuitQueue<tuple_type> batch_type; |
typedef circuit::CircuitQueue<tuple_type> batch_type; |
28 |
|
batch_type& elements(); |
|
29 |
|
const batch_type& elements() const; |
|
|
28 |
|
batch_type& impl_ref(); |
|
29 |
|
const batch_type& impl_ref() const; |
30 |
30 |
|
|
31 |
31 |
private: |
private: |
32 |
32 |
template <typename U> |
template <typename U> |
33 |
33 |
void invoke(U, T...); |
void invoke(U, T...); |
34 |
34 |
|
|
35 |
|
batch_type m_elements; |
|
|
35 |
|
batch_type m_impl; |
36 |
36 |
}; |
}; |
37 |
37 |
|
|
38 |
38 |
} //control |
} //control |
File src/impl/batch.hxx changed (mode: 100644) (index 39bd122..ba4b49c) |
... |
... |
namespace control { |
5 |
5 |
auto BatchImpl<T...>::hook(function_type callback) -> agent_type |
auto BatchImpl<T...>::hook(function_type callback) -> agent_type |
6 |
6 |
{ |
{ |
7 |
7 |
auto agent(std::make_shared<function_type>(callback)); |
auto agent(std::make_shared<function_type>(callback)); |
8 |
|
m_elements.push(std::make_tuple<pointer_type, bool>(agent, true)); |
|
|
8 |
|
impl_ref().push(std::make_tuple<pointer_type, bool>(agent, true)); |
9 |
9 |
return agent; |
return agent; |
10 |
10 |
} |
} |
11 |
11 |
|
|
|
... |
... |
namespace control { |
14 |
14 |
auto BatchImpl<T...>::hook_once(function_type callback) -> agent_type |
auto BatchImpl<T...>::hook_once(function_type callback) -> agent_type |
15 |
15 |
{ |
{ |
16 |
16 |
auto agent(std::make_shared<function_type>(callback)); |
auto agent(std::make_shared<function_type>(callback)); |
17 |
|
m_elements.push(std::make_tuple<pointer_type, bool>(agent, false)); |
|
|
17 |
|
impl_ref().push(std::make_tuple<pointer_type, bool>(agent, false)); |
18 |
18 |
return agent; |
return agent; |
19 |
19 |
} |
} |
20 |
20 |
|
|
|
... |
... |
namespace control { |
23 |
23 |
void BatchImpl<T...>::invoke(T... arg) |
void BatchImpl<T...>::invoke(T... arg) |
24 |
24 |
{ |
{ |
25 |
25 |
batch_type traverse; |
batch_type traverse; |
26 |
|
traverse.swap(elements()); |
|
|
26 |
|
traverse.swap(impl_ref()); |
27 |
27 |
tuple_type agent; |
tuple_type agent; |
28 |
28 |
while (traverse.check_pop(agent)) { |
while (traverse.check_pop(agent)) { |
29 |
29 |
agent_type s(std::get<0>(agent).lock()); |
agent_type s(std::get<0>(agent).lock()); |
|
... |
... |
namespace control { |
32 |
32 |
} |
} |
33 |
33 |
s = std::get<0>(agent).lock(); |
s = std::get<0>(agent).lock(); |
34 |
34 |
if (s && std::get<1>(agent)) { |
if (s && std::get<1>(agent)) { |
35 |
|
elements().push(std::move(agent)); |
|
|
35 |
|
impl_ref().push(std::move(agent)); |
36 |
36 |
} |
} |
37 |
37 |
} |
} |
38 |
38 |
} |
} |
39 |
39 |
|
|
40 |
40 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
41 |
41 |
template <typename... T> |
template <typename... T> |
42 |
|
auto BatchImpl<T...>::elements() -> batch_type& |
|
|
42 |
|
auto BatchImpl<T...>::impl_ref() -> batch_type& |
43 |
43 |
{ |
{ |
44 |
|
return m_elements; |
|
|
44 |
|
return m_impl; |
45 |
45 |
} |
} |
46 |
46 |
|
|
47 |
47 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
48 |
48 |
template <typename... T> |
template <typename... T> |
49 |
|
auto BatchImpl<T...>::elements() const -> const batch_type& |
|
|
49 |
|
auto BatchImpl<T...>::impl_ref() const -> const batch_type& |
50 |
50 |
{ |
{ |
51 |
|
return m_elements; |
|
|
51 |
|
return m_impl; |
52 |
52 |
} |
} |
53 |
53 |
} // control |
} // control |
54 |
54 |
} // om636 |
} // om636 |