Skip to content

Commit 2b4c640

Browse files
committed
more cleaning
1 parent 046acb4 commit 2b4c640

File tree

11 files changed

+102
-47
lines changed

11 files changed

+102
-47
lines changed

examples/multiport_mutation/consumer.hh

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
8+
19
#ifndef CONSUMER_HH // NOLINT
210
#define CONSUMER_HH // NOLINT
311

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
#ifndef LOAD_BALANCER_HH // NOLINT
2-
#define LOAD_BALANCER_HH // NOLINT
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
38

4-
#include <reactor-cpp/reactor-cpp.hh>
9+
#ifndef MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
10+
#define MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
511

6-
#include "reactor-cpp/mutations/multiport.hh"
12+
#include <reactor-cpp/mutations/multiport.hh>
13+
#include <reactor-cpp/reactor-cpp.hh>
714

815
using namespace reactor;
916
using namespace std::chrono_literals;
@@ -19,24 +26,21 @@ class LoadBalancer final : public Reactor { // NOLINT
1926
if (std::rand() % 15 == 0) { // NOLINT
2027
scale_bank.set(std::rand() % 20 + 1); // NOLINT
2128
}
22-
const unsigned sel = std::rand() % outbound.size(); // NOLINT
23-
// std::cout << "Sending out to:" << sel << '\n';
24-
outbound[sel].set(inbound.get());
25-
outbound[std::min(4ul, outbound.size() - 1)].set(inbound.get());
29+
const unsigned outbound_port = std::rand() % outbound.size(); // NOLINT
30+
outbound[outbound_port].set(inbound.get());
2631
}
2732

2833
friend LoadBalancer;
2934
};
3035

3136
Inner _lf_inner;
32-
Reaction process{"process", 2, this, [this]() { Inner::reaction_1(this->inbound, this->scale_bank, this->out); }};
37+
Reaction process{"process", 1, this, [this]() { Inner::reaction_1(this->inbound, this->scale_bank, this->out); }};
3338

3439
public:
3540
LoadBalancer(const std::string& name, Environment* env)
3641
: Reactor(name, env)
3742
, _lf_inner(this) {
3843
out.reserve(4);
39-
std::cout << "creating instance of load balancer" << '\n';
4044
for (size_t _lf_idx = 0; _lf_idx < 4; _lf_idx++) {
4145
out.create_new_port();
4246
}
@@ -45,16 +49,16 @@ public:
4549

4650
ModifableMultiport<Output<unsigned>> out{"out", this}; // NOLINT
4751
std::size_t out_size_ = 0;
52+
4853
Input<unsigned> inbound{"inbound", this}; // NOLINT
4954
Output<unsigned> scale_bank{"scale_bank", this}; // NOLINT
5055

5156
void assemble() override {
52-
std::cout << "assemble LoadBalancer\n";
5357
for (auto& _lf_port : out) {
5458
process.declare_antidependency(&_lf_port);
5559
}
5660
process.declare_trigger(&inbound);
5761
}
5862
};
5963

60-
#endif // LOAD_BALANCER_HH
64+
#endif // MULTIPORT_MUTATION_LOAD_BALANCER_HH

examples/multiport_mutation/main.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
8+
19
#include <iostream>
210
#include <memory>
311

4-
#include <reactor-cpp/mutations/bank.hh>
5-
#include <reactor-cpp/mutations/connection.hh>
12+
#include <reactor-cpp/reactor-cpp.hh>
613

714
#include "./consumer.hh"
815
#include "./load_balancer.hh"
916
#include "./multiport_to_bank.hh"
1017
#include "./producer.hh"
11-
#include <reactor-cpp/reactor-cpp.hh>
1218

1319
class Deployment final : public Reactor { // NOLINT
1420

examples/multiport_mutation/multiport_to_bank.hh

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
//
2-
// Created by tanneberger on 1/13/25.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

5-
#ifndef MULTIPORT_TO_BANK_HH
6-
#define MULTIPORT_TO_BANK_HH
9+
#ifndef MULTIPORT_MUTATION_MULTIPORT_TO_BANK_HH
10+
#define MULTIPORT_MUTATION_MULTIPORT_TO_BANK_HH
711

812
#include <reactor-cpp/multiport.hh>
913
#include <reactor-cpp/mutations.hh>
@@ -88,4 +92,4 @@ public:
8892
};
8993
} // namespace reactor
9094

91-
#endif // MULTIPORT_TO_BANK_HH
95+
#endif // MULTIPORT_MUTATION_MULTIPORT_TO_BANK_HH

examples/multiport_mutation/producer.hh

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
#ifndef PRODUCER_HH // NOLINT
2-
#define PRODUCER_HH // NOLINT
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
8+
9+
#ifndef MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
10+
#define MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
311

412
#include <reactor-cpp/reactor-cpp.hh>
513

@@ -44,4 +52,4 @@ public:
4452
}
4553
};
4654

47-
#endif // PRODUCER_HH
55+
#endif // MULTIPORT_MUTATION_PRODUCER_HH

include/reactor-cpp/mutations/bank.hh

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
//
2-
// Created by tanneberger on 11/18/24.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

59
#ifndef REACTOR_CPP_MUTATIONS_BANK_HH
610
#define REACTOR_CPP_MUTATIONS_BANK_HH

include/reactor-cpp/mutations/connection.hh

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
//
2-
// Created by tanneberger on 11/18/24.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

59
#ifndef REACTOR_CPP_MUTATIONS_CONNECTION_HH
610
#define REACTOR_CPP_MUTATIONS_CONNECTION_HH

include/reactor-cpp/mutations/multiport.hh

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
//
2-
// Created by tanneberger on 11/11/24.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

59
#ifndef REACTOR_CPP_MUTATIONS_MULTIPORT_HH
610
#define REACTOR_CPP_MUTATIONS_MULTIPORT_HH

lib/mutations/bank.cc

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
//
2-
// Created by tanneberger on 11/11/24.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

59
#include "reactor-cpp/mutations/bank.hh"
610
#include "reactor-cpp/action.hh"
@@ -10,17 +14,17 @@ reactor::MutationChangeBankSize<T>::MutationChangeBankSize(
1014
std::vector<T>* bank, Environment* env, std::size_t size,
1115
std::function<T(Environment* env, std::size_t index)> create_lambda)
1216
: bank_(bank)
13-
, env_(env)
1417
, desired_size_(size)
18+
, env_(env)
1519
, create_lambda_(std::move(create_lambda)) {}
1620

1721
template <class T> void reactor::MutationChangeBankSize<T>::change_size(std::size_t new_size) {
1822
auto current_size = bank_->size();
1923

20-
if (current_size >= new_size) { // downscale
24+
if (current_size >= new_size) { // down-size
2125
bank_->resize(new_size);
2226

23-
} else { // upscale
27+
} else { // up-size
2428
bank_->reserve(new_size);
2529

2630
for (auto i = 0; i < new_size - current_size; i++) {

lib/mutations/connection.cc

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
8+
19
#include "reactor-cpp/mutations/connection.hh"
210
#include "reactor-cpp/reactor.hh"
311

4-
#include <reactor-cpp/port.hh>
5-
612
template <class A, class B>
713
reactor::MutationAddConnection<A, B>::MutationAddConnection(A* source, B* sink, Environment* env, bool add_connection)
814
: source_(source)

lib/mutations/multiport.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
//
2-
// Created by tanneberger on 11/11/24.
3-
//
1+
/*
2+
* Copyright (C) 2025 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
48

59
#include "reactor-cpp/mutations/multiport.hh"
6-
#include "reactor-cpp/reaction.hh"
710

811
template <class T>
912
reactor::MutationChangeOutputMultiportSize<T>::MutationChangeOutputMultiportSize(
@@ -14,11 +17,11 @@ reactor::MutationChangeOutputMultiportSize<T>::MutationChangeOutputMultiportSize
1417
template <class T> void reactor::MutationChangeOutputMultiportSize<T>::change_size(std::size_t new_size) {
1518
auto current_size = multiport_->size();
1619
if (current_size >= new_size) {
17-
// downscale
20+
// down-size
1821
multiport_->resize(new_size);
1922

2023
} else {
21-
// upscale
24+
// up-size
2225
multiport_->reserve(new_size);
2326
for (auto i = 0; i < new_size - current_size; i++) {
2427
std::string port_name_ = multiport_->name() + "_" + std::to_string(current_size + i);

0 commit comments

Comments
 (0)