List of commits:
Subject Hash Author Date (UTC)
update dynamo and circuit 672bd2e329424816373f463183415e08cb858543 mucbuc 2020-02-17 00:52:40
format, update cb54c865eff013e4abb6ef86c54814b52b46257e mucbuc 2020-02-14 05:36:21
gen docs c9de816e21d2953c7ac4e73f0be3ccd440c84381 mucbuc 2020-02-12 14:13:08
rm twice-size dc7df761559ee90e089ff274290da3628f429a30 mucbuc 2020-02-12 13:43:34
update libs 177bc958e60841f894a4c9c4d5758db38e07a5c3 mucbuc 2020-02-12 13:22:59
once tests 9aae5bf8c8a46439e7b350c4166c1be22c6028bf mucbuc 2020-01-20 20:08:50
once a72a9ea4d78e082b0e4e6a8545af92e116bd7536 mucbuc 2020-01-20 17:32:34
dynamo 25b14b6965bb24b21516dde3f4a2a1922d518ae5 mucbuc 2020-01-20 17:27:35
concurrent test passes 2bd62976d536c8c81659453e899a2e9c588f4aa6 mucbuc 2020-01-20 12:54:46
update dynamo 3315ba6e643d56478aaf05761368d76e9025de79 mucbuc 2020-01-20 12:13:05
circular update 7545023e77dcb92f28612a62b6405cb488adddc8 mucbuc 2020-01-19 12:09:22
cleanup remove stuff abe9e96601cdfc558823e6d856d16dac8ad15929 mucbuc 2020-01-19 11:52:54
circut update 4d75370846cd93032a684b5193494273a9ba9da9 mucbuc 2020-01-19 11:50:21
dynamoe update 814d85ebb0c03dddfd2d804d404286cc01209687 mucbuc 2020-01-19 06:59:11
simplify interfiace f69d4f7a7c2c02125ac51ffb9d4ba41ed08f8646 mucbuc 2020-01-19 06:41:36
fix another test fd8e7fa14a4daa281e7fbcec875bfe56ce39e400 mucbuc 2020-01-18 22:42:40
working on tests 1b57cbb4e806eda21565dc8bd7e7fe7ff1cb5fff mucbuc 2020-01-18 22:36:15
fix test 8b364e739d1e12cd77b9f63efb0a245a75e695df mucbuc 2020-01-18 21:49:21
fix emit once 71aba1ef472aa23c9c9a8529b5258599a6289c16 mucbuc 2020-01-18 21:41:03
remove agentlifetime test ce0fba661c6110fc050203a1a8f9fedf39258615 mucbuc 2020-01-18 11:25:44
Commit 672bd2e329424816373f463183415e08cb858543 - update dynamo and circuit
Author: mucbuc
Author date (UTC): 2020-02-17 00:52
Committer name: mucbuc
Committer date (UTC): 2020-02-17 00:52
Parent(s): cb54c865eff013e4abb6ef86c54814b52b46257e
Signing key:
Tree: f9b6d6f4884ff4b9529fdfe69768ec1394956fdd
File Lines added Lines deleted
test/lib/circuit/src/impl/stack.h 1 1
test/lib/dynamo/EXAMPLE.md 25 0
test/lib/dynamo/OTHER.md 9 0
test/lib/dynamo/README.md 62 37
test/lib/dynamo/def.json 1 0
test/lib/dynamo/package.json 4 1
test/lib/dynamo/src/dynamofwd.h 2 2
test/lib/dynamo/src/factory.h 25 0
test/lib/dynamo/src/impl/batch.h 8 7
test/lib/dynamo/src/impl/batch.hxx 25 22
test/lib/dynamo/test/example.json 2 3
test/lib/dynamo/test/lib/circuit/.gitignore 2 1
test/lib/dynamo/test/lib/circuit/EXAMPLE.md 0 0
test/lib/dynamo/test/lib/circuit/README.md 46 5
test/lib/dynamo/test/lib/circuit/package.json 3 2
test/lib/dynamo/test/lib/circuit/src/impl/circuit_host.h 2 0
test/lib/dynamo/test/lib/circuit/src/impl/circuit_host.hxx 23 2
test/lib/dynamo/test/lib/circuit/src/impl/queue.h 8 0
test/lib/dynamo/test/lib/circuit/src/impl/stack.h 9 1
test/lib/dynamo/test/lib/circuit/src/index.h 5 6
test/lib/dynamo/test/lib/circuit/src/interface.h 1 1
test/lib/dynamo/test/lib/circuit/test/example.json 0 0
test/lib/dynamo/test/lib/circuit/test/src/example.cpp 0 0
test/lib/dynamo/test/lib/circuit/test/src/main.cpp 0 1
test/lib/dynamo/test/src/batch.h 12 9
test/lib/dynamo/test/src/example.cpp 17 0
File test/lib/circuit/src/impl/stack.h changed (mode: 100644) (index 4f0cdea..20c2f4c)
... ... namespace circuit {
30 30 { {
31 31 ASSERT(lhs.is_locked()); ASSERT(lhs.is_locked());
32 32 ASSERT(rhs.is_locked()); ASSERT(rhs.is_locked());
33 lhs.m_stack.swap(rhs);
33 lhs.m_stack.swap(rhs.m_stack);
34 34 } }
35 35
36 36 template <class U> template <class U>
File test/lib/dynamo/EXAMPLE.md added (mode: 100644) (index 0000000..12bd3ec)
1 const fs = require('fs'),
2 path = require('path'),
3 tbt = "```";
4
5 template = `
6 ## Example
7 ${tbt}
8 #include <tmp/src/test.h>
9
10 #include <lib/dynamo/src/factory.h>
11 #include <lib/dynamo/src/interface.h>
12
13 int main()
14 {
15 auto b = om636::control::make_batch<int>();
16
17 int sum { 0 };
18
19 auto q = b->hook([&](int i) { sum += i; });
20 auto p = b->hook([&](int i) { sum *= i; });
21 b->invoke(5);
22 return sum == 25;
23 }
24 ${tbt}
25 `;
File test/lib/dynamo/OTHER.md added (mode: 100644) (index 0000000..e9471d9)
1 template = `### Dependencies
2
3 Dynamo uses Circuit for thread syncronization
4
5 ### Plan
6
7 Instead of copy and insert elements inside of invok, push the elements one by one as they get traversed (obviosly don't add elements that are dead)...
8
9 ![doc header](https://s3-us-west-2.amazonaws.com/mod-resources/mod-header.svg)`;
File test/lib/dynamo/README.md changed (mode: 100644) (index 64a5f8e..d9f92fc)
1 ## dynamo
2
3 ### Objective:
4
5 Dispatch work to agents.
6
7 ### Interface:
8 ```
9 namespace om636 {
10 namespace control {
11
12 template <typename... T>
13 class Batch {
14 public:
15 typedef std::function<void(T...)> function_type;
16 typedef std::shared_ptr<function_type> agent_type;
17 typedef agent_type listener_type;
18
19 virtual ~Batch() = default;
20 virtual agent_type hook(function_type) = 0;
21 virtual agent_type hook_once(function_type) = 0;
22 virtual void invoke(T...) = 0;
23 };
24
25 } // control
26 } // om636
27 ```
28
29 ### Dependencies
30
31 Dynamo uses Circuit for thread syncronization
32
33 ### Plan
34
35 Instead of copy and insert elements inside of invok, push the elements one by one as they get traversed (obviosly don't add elements that are dead)...
36
37 ![doc header](https://s3-us-west-2.amazonaws.com/mod-resources/mod-header.svg)
1 # dynamo
2
3 Dispatch work to agents.
4
5 ## Interface
6 ```
7 #pragma once
8
9 #include <functional>
10 #include <memory>
11
12 namespace om636 {
13 namespace control {
14
15 template <typename... T>
16 class Batch {
17 public:
18 typedef std::function<void(T...)> function_type;
19 typedef std::shared_ptr<function_type> agent_type;
20 typedef agent_type listener_type;
21
22 virtual ~Batch() = default;
23 virtual agent_type hook(function_type) = 0;
24 virtual agent_type hook_once(function_type) = 0;
25 virtual void invoke(T...) = 0;
26 };
27
28 } // control
29 } // om636
30
31 ```
32
33
34 ## Example
35 ```
36 #include <tmp/src/test.h>
37
38 #include <lib/dynamo/src/factory.h>
39 #include <lib/dynamo/src/interface.h>
40
41 int main()
42 {
43 auto b = om636::control::make_batch<int>();
44
45 int sum { 0 };
46
47 auto q = b->hook([&](int i) { sum += i; });
48 auto p = b->hook([&](int i) { sum *= i; });
49 b->invoke(5);
50 return sum == 25;
51 }
52 ```
53
54 ### Dependencies
55
56 Dynamo uses Circuit for thread syncronization
57
58 ### Plan
59
60 Instead of copy and insert elements inside of invok, push the elements one by one as they get traversed (obviosly don't add elements that are dead)...
61
62 ![doc header](https://s3-us-west-2.amazonaws.com/mod-resources/mod-header.svg)
File test/lib/dynamo/def.json changed (mode: 100644) (index 2500050..14fd57a)
1 1 { {
2 2 "sources": [ "sources": [
3 3 "src/dynamofwd.h", "src/dynamofwd.h",
4 "src/factory.h",
4 5 "src/interface.h", "src/interface.h",
5 6 "src/impl/batch.h", "src/impl/batch.h",
6 7 "src/impl/batch.hxx" "src/impl/batch.hxx"
File test/lib/dynamo/package.json changed (mode: 100644) (index 2312c3b..144fa6f)
1 1 { "version":"0.0.0", { "version":"0.0.0",
2 "description":"Dispatch work to agents.",
2 3 "name":"dynamo", "name":"dynamo",
3 4 "scripts": { "scripts": {
4 "test": "crimp test/test.json -g"
5 "test": "crimp test/test.json -g",
6 "generateDocs":"doc-tool package_header src_interface ./EXAMPLE.md ./OTHER.md > README.md",
7 "format": "clang-format -i --style=Webkit src/*.h src/impl/*.h src/impl/*.hxx test/src/*.cpp"
5 8 } }
6 9 } }
File test/lib/dynamo/src/dynamofwd.h changed (mode: 100644) (index 88057a0..402d909)
2 2
3 3 namespace om636 { namespace om636 {
4 4 namespace control { namespace control {
5 template <typename ...>
5 template <typename...>
6 6 struct Agent; struct Agent;
7 7
8 template <typename ...>
8 template <typename...>
9 9 struct Batch; struct Batch;
10 10 } }
11 11 } }
File test/lib/dynamo/src/factory.h added (mode: 100644) (index 0000000..42965c5)
1 #pragma once
2
3 #include "impl/batch.h"
4
5 #include <lib/circuit/src/impl/queue.h>
6 #include <lib/circuit/src/impl/stack.h>
7
8 namespace om636 {
9
10 namespace control {
11 template <typename... T>
12 std::shared_ptr<Batch<T...>> make_queue()
13 {
14 return std::make_shared<BatchImpl<om636::circuit::QueuePolicy, T...>>();
15 }
16
17 template <typename... T>
18 std::shared_ptr<Batch<T...>> make_stack()
19 {
20 return std::make_shared<BatchImpl<om636::circuit::StackPolicy, T...>>();
21 }
22
23 }
24
25 }
File test/lib/dynamo/src/impl/batch.h changed (mode: 100644) (index ca98a2f..a7c8267)
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 template <typename... T>
13
14 template <template <typename> typename P, typename... T>
14 15 class BatchImpl : public Batch<T...> { class BatchImpl : public Batch<T...> {
15 16 public: public:
16 17 typedef Batch<T...> base_type; typedef Batch<T...> base_type;
 
... ... namespace control {
23 24 void invoke(T...) override; void invoke(T...) override;
24 25
25 26 typedef std::weak_ptr<typename agent_type::element_type> pointer_type; typedef std::weak_ptr<typename agent_type::element_type> pointer_type;
26 typedef std::tuple<pointer_type, bool> tuple_type;
27 typedef circuit::CircuitQueue<tuple_type> batch_type;
28 batch_type& elements();
29 const batch_type& elements() const;
27 typedef std::tuple<pointer_type, bool> tuple_type;
28 typedef circuit::CircuitHost<tuple_type, P> batch_type;
29 batch_type& impl_ref();
30 const batch_type& impl_ref() const;
30 31
31 32 private: private:
32 33 template <typename U> template <typename U>
33 34 void invoke(U, T...); void invoke(U, T...);
34 35
35 batch_type m_elements;
36 batch_type m_impl;
36 37 }; };
37 38
38 39 } //control } //control
File test/lib/dynamo/src/impl/batch.hxx changed (mode: 100644) (index 3bac54b..013aa65)
1 1 namespace om636 { namespace om636 {
2 2 namespace control { namespace control {
3 3 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
4 template <typename... T>
5 auto BatchImpl<T...>::hook(function_type callback) -> agent_type
4 template <template <typename> typename P, typename... T>
5 auto BatchImpl<P, T...>::hook(function_type callback) -> agent_type
6 6 { {
7 auto agent(std::make_shared<function_type>(callback));
8 m_elements.push(std::make_tuple<pointer_type, bool>(agent, true));
7 using namespace std;
8 auto agent(make_shared<function_type>(callback));
9 impl_ref().push(make_tuple<pointer_type, bool>(agent, true));
9 10 return agent; return agent;
10 11 } }
11 12
12 13 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
13 template <typename... T>
14 auto BatchImpl<T...>::hook_once(function_type callback) -> agent_type
14 template <template <typename> typename P, typename... T>
15 auto BatchImpl<P, T...>::hook_once(function_type callback) -> agent_type
15 16 { {
16 auto agent(std::make_shared<function_type>(callback));
17 m_elements.push(std::make_tuple<pointer_type, bool>(agent, false));
17 using namespace std;
18 auto agent(make_shared<function_type>(callback));
19 impl_ref().push(make_tuple<pointer_type, bool>(agent, false));
18 20 return agent; return agent;
19 21 } }
20 22
21 23 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
22 template <typename... T>
23 void BatchImpl<T...>::invoke(T... arg)
24 template <template <typename> typename P, typename... T>
25 void BatchImpl<P, T...>::invoke(T... arg)
24 26 { {
27 using namespace std;
25 28 batch_type traverse; batch_type traverse;
26 traverse.swap(elements());
29 traverse.swap(impl_ref());
27 30 tuple_type agent; tuple_type agent;
28 31 while (traverse.check_pop(agent)) { while (traverse.check_pop(agent)) {
29 agent_type s(std::get<0>(agent).lock());
32 agent_type s(get<0>(agent).lock());
30 33 if (s) { if (s) {
31 34 (*s)(arg...); (*s)(arg...);
32 }
33 s = std::get<0>(agent).lock();
34 if (s && std::get<1>(agent)) {
35 elements().push(std::move(agent));
35 }
36 s = get<0>(agent).lock();
37 if (s && get<1>(agent)) {
38 impl_ref().push(move(agent));
36 39 } }
37 40 } }
38 41 } }
39 42
40 43 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
41 template <typename... T>
42 auto BatchImpl<T...>::elements() -> batch_type&
44 template <template <typename> typename P, typename... T>
45 auto BatchImpl<P, T...>::impl_ref() -> batch_type&
43 46 { {
44 return m_elements;
47 return m_impl;
45 48 } }
46 49
47 50 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
48 template <typename... T>
49 auto BatchImpl<T...>::elements() const -> const batch_type&
51 template <template <typename> typename P, typename... T>
52 auto BatchImpl<P, T...>::impl_ref() const -> const batch_type&
50 53 { {
51 return m_elements;
54 return m_impl;
52 55 } }
53 56 } // control } // control
54 57 } // om636 } // om636
File test/lib/dynamo/test/example.json copied from file test/lib/dynamo/test/test.json (similarity 63%) (mode: 100644) (index b632f06..7bb83e4)
3 3 "lib/dynamo/def.json" "lib/dynamo/def.json"
4 4 ], ],
5 5 "sources": [ "sources": [
6 "src/main.cpp",
7 "src/batch.h"
6 "src/example.cpp"
8 7 ] ]
9 }
8 }
File test/lib/dynamo/test/lib/circuit/.gitignore changed (mode: 100644) (index 6f7455b..9b920a4)
1 1 .DS_Store .DS_Store
2 node_modules/
2 3 test/tmp test/tmp
3 test/lib
4 test/lib
File test/lib/dynamo/test/lib/circuit/EXAMPLE.md copied from file test/lib/circuit/EXAMPLE.md (similarity 100%)
File test/lib/dynamo/test/lib/circuit/README.md changed (mode: 100644) (index e8eeb01..7b85e05)
1 ## Objective
1 # circuit
2 2
3 Syncronize container operations (for single objects)
3 Syncronize container operations for single objects
4 4
5 5 ## Interface ## Interface
6 ```
7 #pragma once
8
9 namespace om636 {
10 namespace circuit {
11
12 template <class T>
13 struct Circuit {
14 typedef T value_type;
15
16 virtual ~Circuit() = default;
17 virtual void push(value_type&&) = 0;
18 virtual bool check_pop(value_type&) = 0;
19 virtual void wait_pop(value_type&) = 0;
20 virtual Circuit* clone() const = 0;
21 };
22
23 } // circuit
24 } // om636
6 25
7 26 ``` ```
8 circuit.check_pop(variable)
9 circuit.wait_pop(variable)
10 circuit.push(1);
27
28
29 ## Example
11 30 ``` ```
31 #include <tmp/src/test.h>
32
33 #include <lib/circuit/src/index.h>
34
35 using namespace std;
36 using namespace om636::circuit;
37
38 int main()
39 {
40 CircuitStack<int> s;
41
42 s.push(88);
43 s.push(77);
44
45 int i;
46 s.wait_pop(i);
47 if (s.check_pop(i)) {
48
49 }
50 }
51 ```
52
File test/lib/dynamo/test/lib/circuit/package.json changed (mode: 100644) (index 46fc3d5..5a7c3ec)
1 1 { {
2 2 "name": "circuit", "name": "circuit",
3 3 "version": "1.0.0", "version": "1.0.0",
4 "description": "",
4 "description": "Syncronize container operations for single objects",
5 5 "main": "index.js", "main": "index.js",
6 6 "directories": { "directories": {
7 7 "test": "test" "test": "test"
8 8 }, },
9 9 "scripts": { "scripts": {
10 10 "test": "crimp -g test/test.json", "test": "crimp -g test/test.json",
11 "format": "clang-format -i --style=Webkit src/*.h src/impl/*.h src/impl/*.hxx test/src/*.cpp"
11 "format": "clang-format -i --style=Webkit src/*.h src/impl/*.h src/impl/*.hxx test/src/*.cpp",
12 "generateDoc": "doc-tool package_header src_interface ./EXAMPLE.md > README.md"
12 13 }, },
13 14 "author": "", "author": "",
14 15 "license": "ISC" "license": "ISC"
File test/lib/dynamo/test/lib/circuit/src/impl/circuit_host.h changed (mode: 100644) (index be202e3..375f033)
... ... namespace circuit {
17 17 using typename base_type::value_type; using typename base_type::value_type;
18 18
19 19 CircuitHost() = default; CircuitHost() = default;
20 CircuitHost(const CircuitHost&);
20 21 CircuitHost(CircuitHost&&); CircuitHost(CircuitHost&&);
21 22 CircuitHost& operator=(CircuitHost); CircuitHost& operator=(CircuitHost);
22 23
 
... ... namespace circuit {
28 29 void push(value_type&&) override; void push(value_type&&) override;
29 30 bool check_pop(value_type&) override; bool check_pop(value_type&) override;
30 31 void wait_pop(value_type&) override; void wait_pop(value_type&) override;
32 CircuitHost* clone() const override;
31 33
32 34 private: private:
33 35 typedef U<T> policy_type; typedef U<T> policy_type;
File test/lib/dynamo/test/lib/circuit/src/impl/circuit_host.hxx changed (mode: 100644) (index 178dfb8..fdf9742)
1 1 namespace om636 { namespace om636 {
2 2 namespace circuit { namespace circuit {
3 3
4 /////////////////////////////////////////////////////////////////////////////////////////////
5 template <typename T, template <typename> class U>
6 CircuitHost<T, U>::CircuitHost(const CircuitHost& rhs)
7 {
8 typedef std::unique_lock<mutex_type> lock_type;
9
10 lock_type left_lock(m_mutex, std::defer_lock);
11 lock_type right_lock(rhs.m_mutex, std::defer_lock);
12 std::lock(left_lock, right_lock);
13
14 policy_type::on_copy(*this, rhs);
15 }
16
4 17 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
5 18 template <typename T, template <typename> class U> template <typename T, template <typename> class U>
6 19 CircuitHost<T, U>::CircuitHost(CircuitHost&& rhs) CircuitHost<T, U>::CircuitHost(CircuitHost&& rhs)
 
... ... namespace circuit {
48 61 bool result(false); bool result(false);
49 62 std::thread([this, &result]() { std::thread([this, &result]() {
50 63 result = m_mutex.try_lock(); result = m_mutex.try_lock();
51 if (result) {
52 m_mutex.unlock();
64 if (result) {
65 m_mutex.unlock();
53 66 } }
54 67 }).join(); }).join();
55 68 return !result; return !result;
 
... ... namespace circuit {
86 99 m_condition.wait(lock, [this] { return !policy_type::on_empty(*this); }); m_condition.wait(lock, [this] { return !policy_type::on_empty(*this); });
87 100 policy_type::on_pop(*this, value); policy_type::on_pop(*this, value);
88 101 } }
102
103 /////////////////////////////////////////////////////////////////////////////////////////////
104 template <typename T, template <typename> class U>
105 auto CircuitHost<T, U>::clone() const -> CircuitHost*
106 {
107 return new CircuitHost(*this);
108 }
109
89 110 } // circuit } // circuit
90 111 } // om636 } // om636
File test/lib/dynamo/test/lib/circuit/src/impl/queue.h changed (mode: 100644) (index bc763a3..b4aaa20)
... ... namespace circuit {
17 17 lhs.m_queue = std::move(rhs.m_queue); lhs.m_queue = std::move(rhs.m_queue);
18 18 } }
19 19
20 template <class U>
21 static void on_copy(U& lhs, const U& rhs)
22 {
23 ASSERT(lhs.is_locked());
24 ASSERT(rhs.is_locked());
25 lhs.m_queue = rhs.m_queue;
26 }
27
20 28 template <class U> template <class U>
21 29 static void on_swap(U& lhs, U& rhs) static void on_swap(U& lhs, U& rhs)
22 30 { {
File test/lib/dynamo/test/lib/circuit/src/impl/stack.h changed (mode: 100644) (index bdbf6ac..20c2f4c)
... ... namespace circuit {
9 9 struct StackPolicy { struct StackPolicy {
10 10 typedef T value_type; typedef T value_type;
11 11
12 template <class U>
13 static void on_copy(U& lhs, const U& rhs)
14 {
15 ASSERT(lhs.is_locked());
16 ASSERT(rhs.is_locked());
17 lhs.m_stack = rhs.m_stack;
18 }
19
12 20 template <class U> template <class U>
13 21 static void on_init(U& lhs, U&& rhs) static void on_init(U& lhs, U&& rhs)
14 22 { {
 
... ... namespace circuit {
22 30 { {
23 31 ASSERT(lhs.is_locked()); ASSERT(lhs.is_locked());
24 32 ASSERT(rhs.is_locked()); ASSERT(rhs.is_locked());
25 lhs.m_stack.swap(rhs);
33 lhs.m_stack.swap(rhs.m_stack);
26 34 } }
27 35
28 36 template <class U> template <class U>
File test/lib/dynamo/test/lib/circuit/src/index.h changed (mode: 100644) (index 1742512..aac2bba)
1 1 #pragma once #pragma once
2 2
3 3 #include "impl/circuit_host.h" #include "impl/circuit_host.h"
4 #include "impl/stack.h"
5 4 #include "impl/queue.h" #include "impl/queue.h"
5 #include "impl/stack.h"
6 6
7 7 namespace om636 { namespace om636 {
8 8 namespace circuit { namespace circuit {
9 9
10 template<typename T>
11 using CircuitStack = CircuitHost<T, StackPolicy>;
10 template <typename T>
11 using CircuitStack = CircuitHost<T, StackPolicy>;
12 12
13 template<typename T>
14 using CircuitQueue = CircuitHost<T, QueuePolicy>;
13 template <typename T>
14 using CircuitQueue = CircuitHost<T, QueuePolicy>;
15 15
16 16 } // circuit } // circuit
17 17 } // om636 } // om636
18
File test/lib/dynamo/test/lib/circuit/src/interface.h changed (mode: 100644) (index 32d8ab4..8b562d1)
... ... namespace circuit {
11 11 virtual void push(value_type&&) = 0; virtual void push(value_type&&) = 0;
12 12 virtual bool check_pop(value_type&) = 0; virtual bool check_pop(value_type&) = 0;
13 13 virtual void wait_pop(value_type&) = 0; virtual void wait_pop(value_type&) = 0;
14 virtual Circuit* clone() const = 0;
14 15 }; };
15 16
16 17 } // circuit } // circuit
17 18 } // om636 } // om636
18
File test/lib/dynamo/test/lib/circuit/test/example.json copied from file test/lib/circuit/test/example.json (similarity 100%)
File test/lib/dynamo/test/lib/circuit/test/src/example.cpp copied from file test/lib/circuit/test/src/example.cpp (similarity 100%)
File test/lib/dynamo/test/lib/circuit/test/src/main.cpp changed (mode: 100644) (index dd6faf3..df6a636)
... ... int main()
25 25 test_wait_pop(std::make_shared<CircuitStack<int>>()); test_wait_pop(std::make_shared<CircuitStack<int>>());
26 26 test_wait_pop(std::make_shared<CircuitQueue<int>>()); test_wait_pop(std::make_shared<CircuitQueue<int>>());
27 27
28
29 28 CircuitQueue<int> a, b; CircuitQueue<int> a, b;
30 29 a.swap(b); a.swap(b);
31 30
File test/lib/dynamo/test/src/batch.h changed (mode: 100644) (index 4097e88..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<> batch;
10 BatchImpl<QueuePolicy> batch;
8 11 unsigned passed(0); unsigned passed(0);
9 12
10 typename BatchImpl<>::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<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);
28 31
29 ASSERT(batch.elements().empty() && "dead agent removal");
32 ASSERT(batch.impl_ref().empty() && "dead agent removal");
30 33 } }
31 34
32 35 void check_traverse_with_arg() void check_traverse_with_arg()
33 36 { {
34 BatchImpl<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<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<> 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<> 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([&]() {
File test/lib/dynamo/test/src/example.cpp added (mode: 100644) (index 0000000..bf159f3)
1 #include <tmp/src/test.h>
2
3 #include <lib/dynamo/src/factory.h>
4 #include <lib/dynamo/src/interface.h>
5
6 int main()
7 {
8 auto b = om636::control::make_stack<int>();
9
10 int sum { 0 };
11
12 auto q = b->hook([&](int i) { sum += i; });
13 auto p = b->hook([&](int i) { sum *= i; });
14 b->invoke(5);
15 ASSERT(sum == 25);
16 return 0;
17 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mucbuc/ohm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mucbuc/ohm

Clone this repository using git:
git clone git://git.rocketgit.com/user/mucbuc/ohm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main