Skip to content

Commit

Permalink
fix Worker name
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed Jul 19, 2022
1 parent a8bd059 commit 0f0d479
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions include/reactor-cpp/scheduler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public:
auto create_worker() -> Worker<DefaultSchedulingPolicy> { return {*this, identity_counter++}; }
};

using DefaultWorker = Worker<DefaultSchedulingPolicy>;

class ReadyQueue {
private:
using Worker = Worker<DefaultSchedulingPolicy>;

std::vector<Reaction*> queue_{};
std::atomic<std::ptrdiff_t> size_{0};
Semaphore sem_{0};
Expand Down Expand Up @@ -113,15 +113,13 @@ using EventMap = std::map<BaseAction*, std::function<void(void)>>;

class Scheduler { // NOLINT
private:
using Worker = Worker<DefaultSchedulingPolicy>;

DefaultSchedulingPolicy policy_;

const bool using_workers_;
LogicalTime logical_time_{};

Environment* environment_;
std::vector<Worker> workers_{};
std::vector<DefaultWorker> workers_{};

std::mutex scheduling_mutex_;
std::unique_lock<std::mutex> scheduling_lock_{scheduling_mutex_, std::defer_lock};
Expand Down
8 changes: 4 additions & 4 deletions lib/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ auto ReadyQueue::pop() -> Reaction* {

// If there is no ready reaction available, wait until there is one.
while (old_size <= 0) {
log::Debug() << "(Worker " << Worker::current_worker_id() << ") Wait for work";
log::Debug() << "(Worker " << DefaultWorker::current_worker_id() << ") Wait for work";
sem_.acquire();
log::Debug() << "(Worker " << Worker::current_worker_id() << ") Waking up";
log::Debug() << "(Worker " << DefaultWorker::current_worker_id() << ") Waking up";
old_size = size_.fetch_sub(1, std::memory_order_acq_rel);
// FIXME: Protect against underflow?
}
Expand Down Expand Up @@ -344,15 +344,15 @@ void Scheduler::set_port(BasePort* port) {
// We do not check here if port is already in the list. This means clean()
// could be called multiple times for a single port. However, calling
// clean() multiple time is not harmful and more efficient then checking if
set_ports_[Worker::current_worker_id()].push_back(port);
set_ports_[DefaultWorker::current_worker_id()].push_back(port);

// recursively search for triggered reactions
set_port_helper(port);
}

void Scheduler::set_port_helper(BasePort* port) {
for (auto* reaction : port->triggers()) {
triggered_reactions_[Worker::current_worker_id()].push_back(reaction);
triggered_reactions_[DefaultWorker::current_worker_id()].push_back(reaction);
}
for (auto* binding : port->outward_bindings()) {
set_port_helper(binding);
Expand Down

0 comments on commit 0f0d479

Please sign in to comment.