Removing buckets::schedule as it's confusing and unnecessary.
This commit is contained in:
parent
32b151b415
commit
50648b27ee
2 changed files with 8 additions and 22 deletions
|
@ -9,9 +9,9 @@
|
|||
void nano::scheduler::buckets::next ()
|
||||
{
|
||||
++current;
|
||||
if (current == schedule.end ())
|
||||
if (current == buckets_m.end ())
|
||||
{
|
||||
current = schedule.begin ();
|
||||
current = buckets_m.begin ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,21 +19,12 @@ void nano::scheduler::buckets::next ()
|
|||
void nano::scheduler::buckets::seek ()
|
||||
{
|
||||
next ();
|
||||
for (std::size_t i = 0, n = schedule.size (); buckets_m[*current]->empty () && i < n; ++i)
|
||||
for (std::size_t i = 0, n = buckets_m.size (); (*current)->empty () && i < n; ++i)
|
||||
{
|
||||
next ();
|
||||
}
|
||||
}
|
||||
|
||||
/** Initialise the schedule vector */
|
||||
void nano::scheduler::buckets::populate_schedule ()
|
||||
{
|
||||
for (auto i = 0; i < buckets_m.size (); ++i)
|
||||
{
|
||||
schedule.push_back (i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritization constructor, construct a container containing approximately 'maximum' number of blocks.
|
||||
* @param maximum number of blocks that this container can hold, this is a soft and approximate limit.
|
||||
|
@ -63,8 +54,7 @@ nano::scheduler::buckets::buckets (uint64_t maximum) :
|
|||
{
|
||||
buckets_m.push_back (std::make_unique<scheduler::bucket> (bucket_max));
|
||||
}
|
||||
populate_schedule ();
|
||||
current = schedule.begin ();
|
||||
current = buckets_m.begin ();
|
||||
}
|
||||
|
||||
nano::scheduler::buckets::~buckets ()
|
||||
|
@ -96,7 +86,7 @@ void nano::scheduler::buckets::push (uint64_t time, std::shared_ptr<nano::block>
|
|||
std::shared_ptr<nano::block> nano::scheduler::buckets::top () const
|
||||
{
|
||||
debug_assert (!empty ());
|
||||
auto result = buckets_m[*current]->top ();
|
||||
auto result = (*current)->top ();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -104,7 +94,7 @@ std::shared_ptr<nano::block> nano::scheduler::buckets::top () const
|
|||
void nano::scheduler::buckets::pop ()
|
||||
{
|
||||
debug_assert (!empty ());
|
||||
auto & bucket = buckets_m[*current];
|
||||
auto & bucket = *current;
|
||||
bucket->pop ();
|
||||
seek ();
|
||||
}
|
||||
|
@ -145,7 +135,7 @@ void nano::scheduler::buckets::dump () const
|
|||
{
|
||||
bucket->dump ();
|
||||
}
|
||||
std::cerr << "current: " << std::to_string (*current) << '\n';
|
||||
std::cerr << "current: " << current - buckets_m.begin () << '\n';
|
||||
}
|
||||
|
||||
std::unique_ptr<nano::container_info_component> nano::scheduler::buckets::collect_container_info (std::string const & name)
|
||||
|
|
|
@ -33,18 +33,14 @@ class buckets final
|
|||
* the container writes a block to the lowest indexed bucket that has balance larger than the bucket's minimum value */
|
||||
std::deque<nano::uint128_t> minimums;
|
||||
|
||||
/** Contains bucket indicies to iterate over when making the next scheduling decision */
|
||||
std::deque<uint8_t> schedule;
|
||||
|
||||
/** index of bucket to read next */
|
||||
decltype (schedule)::const_iterator current;
|
||||
decltype (buckets_m)::const_iterator current;
|
||||
|
||||
/** maximum number of blocks in whole container, each bucket's maximum is maximum / bucket_number */
|
||||
uint64_t const maximum;
|
||||
|
||||
void next ();
|
||||
void seek ();
|
||||
void populate_schedule ();
|
||||
|
||||
public:
|
||||
buckets (uint64_t maximum = 250000u);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue