feisty meow concerns codebase  2.140
sockets::span_manager Class Reference

Manages lists of numbers representing the completion of some activity. More...

#include <span_manager.h>

Public Member Functions

 span_manager (int number_of_items)
 
 span_manager (const span_manager &to_copy)
 
 ~span_manager ()
 
span_manageroperator= (const span_manager &to_copy)
 
void reset (int number_of_items)
 sets up the span manager with a new configuration. More...
 
bool update (const basis::int_array &new_spans)
 updates the span information. More...
 
int received_sequence () const
 returns the highest chunk number at which all chunks are ready. More...
 
int missing_sequence () const
 returns the number of the chunk where the first item is missing. More...
 
void make_received_list (basis::int_array &spans, int max_spans=-1) const
 Creates a list for the received spans that are ready. More...
 
void make_missing_list (basis::int_array &spans, int max_spans=-1) const
 creates a list representing the spans that are not ready yet. More...
 
const structures::bit_vectorvector () const
 observes the held bit_vector that represents the spans. More...
 
structures::bit_vectorvector ()
 provides access to the held bit_vector that represents the spans. More...
 
basis::astring print_received_list () const
 prints out the span list for received blocks into a string. More...
 
basis::astring print_missing_list () const
 prints out the span list for missing blocks into a string. More...
 

Detailed Description

Manages lists of numbers representing the completion of some activity.

A number is either present or absent from the list. The numbers are organized according to spans, where a span is simply a range of numbers, such as 33-238. the span manager allows numbers to be added or removed from the list. it also can create the full list of either the present or absent numbers.

Definition at line 31 of file span_manager.h.

Constructor & Destructor Documentation

◆ span_manager() [1/2]

sockets::span_manager::span_manager ( int  number_of_items)

Definition at line 29 of file span_manager.cpp.

◆ span_manager() [2/2]

sockets::span_manager::span_manager ( const span_manager to_copy)

Definition at line 33 of file span_manager.cpp.

◆ ~span_manager()

sockets::span_manager::~span_manager ( )

Definition at line 37 of file span_manager.cpp.

References basis::WHACK().

Member Function Documentation

◆ make_missing_list()

void sockets::span_manager::make_missing_list ( basis::int_array spans,
int  max_spans = -1 
) const

◆ make_received_list()

void sockets::span_manager::make_received_list ( basis::int_array spans,
int  max_spans = -1 
) const

Creates a list for the received spans that are ready.

The numbers in the list refer to ranges of spans fully received. For example, if 0, 3, 4, 5, 8, 9, 12, 13, 14, and 28 have been received, the span list is [0-0], [3-5], [8-9], [12-14], and [28-28]. The "max_spans" is the longest the list is allowed to be, unless it is negative, which means include all of them.

Definition at line 62 of file span_manager.cpp.

References structures::bit_vector::bits(), basis::array< contents >::concatenate(), structures::bit_vector::find_first(), basis::array< contents >::length(), basis::negative(), structures::bit_vector::on(), and basis::array< contents >::reset().

Referenced by print_received_list().

◆ missing_sequence()

int sockets::span_manager::missing_sequence ( ) const

returns the number of the chunk where the first item is missing.

if none of them are missing, then a negative number is returned.

Definition at line 46 of file span_manager.cpp.

References structures::bit_vector::find_first().

◆ operator=()

span_manager & sockets::span_manager::operator= ( const span_manager to_copy)

Definition at line 39 of file span_manager.cpp.

◆ print_missing_list()

astring sockets::span_manager::print_missing_list ( ) const

prints out the span list for missing blocks into a string.

Definition at line 206 of file span_manager.cpp.

References make_missing_list(), and received_sequence().

◆ print_received_list()

astring sockets::span_manager::print_received_list ( ) const

prints out the span list for received blocks into a string.

Definition at line 197 of file span_manager.cpp.

References make_received_list(), and received_sequence().

◆ received_sequence()

int sockets::span_manager::received_sequence ( ) const

returns the highest chunk number at which all chunks are ready.

or a negative number is returned if chunk 0 has still not been received yet.

Definition at line 55 of file span_manager.cpp.

References structures::bit_vector::bits(), structures::bit_vector::find_first(), and basis::negative().

Referenced by print_missing_list(), and print_received_list().

◆ reset()

void sockets::span_manager::reset ( int  number_of_items)

sets up the span manager with a new configuration.

Definition at line 49 of file span_manager.cpp.

References structures::bit_vector::resize().

◆ update()

bool sockets::span_manager::update ( const basis::int_array new_spans)

updates the span information.

the spans listed in the hold are added to the span manager. if the spans are successfully added, then true is returned.

Definition at line 118 of file span_manager.cpp.

References structures::bit_vector::bits(), basis::array< contents >::get(), basis::array< contents >::length(), and structures::bit_vector::light().

◆ vector() [1/2]

bit_vector & sockets::span_manager::vector ( )

provides access to the held bit_vector that represents the spans.

Definition at line 53 of file span_manager.cpp.

◆ vector() [2/2]

const bit_vector & sockets::span_manager::vector ( ) const

observes the held bit_vector that represents the spans.

Definition at line 51 of file span_manager.cpp.


The documentation for this class was generated from the following files: