Skip to content

Commit

Permalink
Renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 11, 2024
1 parent 8513ba8 commit 00348b3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nano/node/fair_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ class fair_queue final
};

public:
using source_type = origin;
using value_type = std::pair<Request, source_type>;
using origin_type = origin;
using value_type = std::pair<Request, origin_type>;

public:
size_t size (source_type source) const
size_t size (origin_type source) const
{
auto it = queues.find (source);
return it == queues.end () ? 0 : it->second.size ();
}

size_t max_size (source_type source) const
size_t max_size (origin_type source) const
{
auto it = queues.find (source);
return it == queues.end () ? 0 : it->second.max_size;
}

size_t priority (source_type source) const
size_t priority (origin_type source) const
{
auto it = queues.find (source);
return it == queues.end () ? 0 : it->second.priority;
Expand Down Expand Up @@ -159,14 +159,13 @@ class fair_queue final
* Request will be dropped if the queue is full
* @return true if added, false if dropped
*/
bool push (Request request, source_type source)
bool push (Request request, origin_type source)
{
auto it = queues.find (source);

// Create a new queue if it doesn't exist
if (it == queues.end ())
{
// TODO: Right now this is constant and initialized when the queue is created, but it could be made dynamic
auto max_size = max_size_query (source);
auto priority = priority_query (source);

Expand All @@ -180,8 +179,8 @@ class fair_queue final
}

public:
using max_size_query_t = std::function<size_t (source_type const &)>;
using priority_query_t = std::function<size_t (source_type const &)>;
using max_size_query_t = std::function<size_t (origin_type const &)>;
using priority_query_t = std::function<size_t (origin_type const &)>;

max_size_query_t max_size_query{ [] (auto const & origin) { debug_assert (false, "max_size_query callback empty"); return 0; } };
priority_query_t priority_query{ [] (auto const & origin) { debug_assert (false, "priority_query callback empty"); return 0; } };
Expand Down Expand Up @@ -272,8 +271,8 @@ class fair_queue final
}

private:
std::map<source_type, entry> queues;
std::map<source_type, entry>::iterator iterator{ queues.end () };
std::map<origin_type, entry> queues;
std::map<origin_type, entry>::iterator iterator{ queues.end () };
size_t counter{ 0 };

std::chrono::steady_clock::time_point last_update{};
Expand Down

0 comments on commit 00348b3

Please sign in to comment.