Skip to content

Commit

Permalink
Put signal outside
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Dec 13, 2024
1 parent 6219819 commit 6df9a3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
21 changes: 1 addition & 20 deletions src/nrncvode/netcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "nrnneosm.h"
#include "pool.hpp"
#include "tqitem.hpp"
#include "utils/signal.hpp"

#include <InterViews/observe.h>

Expand Down Expand Up @@ -211,26 +212,6 @@ class ConditionEvent: public DiscreteEvent {
static unsigned long deliver_qthresh_;
};

#include <list>

template <typename T>
class signal_ {
public:
template <typename F>
void connect(F f) {
functors.push_back(f);
}

void send(T wc) {
for (auto& f: functors) {
std::invoke(f, wc);
}
}

private:
std::list<std::function<void(T)>> functors;
};

class WatchCondition: public ConditionEvent {
public:
WatchCondition(Point_process*, double (*)(Point_process*));
Expand Down
21 changes: 21 additions & 0 deletions src/utils/signal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma

#include <list>

template <typename T>
class signal_ {
public:
template <typename F>
void connect(F f) {
functors.push_back(f);
}

void send(T wc) {
for (auto& f: functors) {
std::invoke(f, wc);
}
}

private:
std::list<std::function<void(T)>> functors;
};

0 comments on commit 6df9a3b

Please sign in to comment.