Class TimeoutQueue¶
Defined in File rdma_timeout_queue.h
Class Documentation¶
-
class
switchml::TimeoutQueue¶ An efficient data structure used to check for message timeouts.
In order to ensure that all operations are done in constant time, the timeoutqueue was designed using an ordered double-linked list which also has an index for entries. This allows us to perform all of the 3 functions (push, remove, check) in constant time.
Public Types
Public Functions
-
TimeoutQueue(const uint32_t num_entries, const std::chrono::milliseconds timeout, const uint32_t timeouts_threshold, const uint32_t timeouts_threshold_increment)¶ Construct a new Timeout Queue object.
- Parameters
num_entries – [in] The maximum number of entries that you might push. This should equal the number of outstanding messages.
timeout – [in] The initial value of the timeout in milliseconds.
threshold – [in] After how many timeouts should we double the timeout value?.
threshold – [in] After a timeout occurs how much should we increment the threshold?.
-
~TimeoutQueue() = default¶
-
TimeoutQueue(TimeoutQueue const&) = default¶
-
void
operator=(TimeoutQueue const&) = delete¶
-
TimeoutQueue(TimeoutQueue&&) = default¶
-
TimeoutQueue &
operator=(TimeoutQueue&&) = default¶
-
void
Push(int index, const TimePoint ×tamp)¶ Push an entry onto the queue.
Elements are added to the top of the linked list because they are always assumed to be the newest. This allows us to keep the order and insert into the linked list in constant time.
- Parameters
index – [in] The index where you want to store the entry for direct access later. This is not the same as the entry’s position in the linked list.
timestamp – [in] The current timestamp
-
void
Remove(int index)¶ Remove an entry.
This operation is done in constant time since the index gives us direct access to the linked list element and we only then need to rewire the pointers of the two adjacent entries in the linked list if they exist.
- Parameters
index – [in] The index of the entry to remove.
-
int
Check(const TimePoint ×tamp)¶ Given the current timestamp, check a timeout occured.
If a timeout occured, then the index of the entry that timed out first is returned.
This is also done in constant time since we only need to check the entry that exists at the tail of the linked list.
- Parameters
timestamp – [in] The current timestamp.
- Returns
int the index of the entry that timed out first.
-