No history found.

README.md:

dynamo

Dispatch work to agents.

Interface

#pragma once

#include <functional>
#include <memory>

namespace om636 {
namespace control {

    template <typename... T>
    class Batch {
    public:
        typedef std::function<void(T...)> function_type;
        typedef std::shared_ptr<function_type> agent_type;
        typedef agent_type listener_type;

        virtual ~Batch() = default;
        virtual agent_type hook(function_type) = 0;
        virtual agent_type hook_once(function_type) = 0;
        virtual void invoke(T...) = 0;
    };

    template <typename... T>
    std::shared_ptr<Batch<T...>> make_queue();

    template <typename... T>
    std::shared_ptr<Batch<T...>> make_stack();

} // control
} // om636

Example

#include <tmp/src/test.h>

#include <lib/dynamo/src/impl/batch.h>
#include <lib/dynamo/src/interface.h>

int main()
{
    auto b = om636::control::make_queue<int>();

    int sum{ 0 };

    auto q = b->hook([&](int i) { sum += i; });
    auto p = b->hook([&](int i) { sum *= i; });
    b->invoke(5);
    ASSERT(sum == 25);
    return 0;
}

Dependencies

Dynamo uses Circuit for thread syncronization

Plan

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)…

doc header
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/dynamo

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

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

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