Skip to content

Commit

Permalink
DUMP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 10, 2024
1 parent 6602c7c commit 3e99477
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions nano/node/fair_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ class fair_queue final
}

auto operator<=> (source const &) const = default;

friend std::ostream & operator<< (std::ostream & os, source const & source)
{
os << "sources: ";
std::apply ([&os] (auto const &... sources) {
((os << to_string (sources) << ", "), ...);
},
source.sources);
if (source.channel)
{
os << " channel: " << source.channel->to_string ()
<< " (" << source.channel->get_node_id () << ")"
<< " [" << source.channel.get () << "]";
}
return os;
}
};

private:
Expand Down Expand Up @@ -155,11 +171,29 @@ class fair_queue final
cleanup ();
update ();

std::cout << "fair_queue:\n"
<< *this
<< std::endl;

return true; // Updated
}
return false; // Not updated
}

void dump (std::ostream & os) const
{
for (auto const & [source, queue] : queues)
{
os << "queue: " << source << " - " << queue.size () << " / " << queue.max_size << " (priority: " << queue.priority << ")\n";
}
}

friend std::ostream & operator<< (std::ostream & os, fair_queue const & queue)
{
queue.dump (os);
return os;
}

/**
* Push a request to the appropriate queue based on the source
* Request will be dropped if the queue is full
Expand Down

0 comments on commit 3e99477

Please sign in to comment.