# Kite - Detailed Router

Public Member Functions | List of all members
RoutingEventLoop Class Reference

Simple loop dectector for RoutingEvent. More...

## Public Member Functions

| RoutingEventLoop (size_t depth=10, int limit=20)
bool | isLooping () const
int | getMaxCount () const
const std::vector< Element > & | getElements () const
void | update (size_t id)
void | erase (size_t id)

## Detailed Description

Simple loop dectector for RoutingEvent.

The RoutingEventLoop can be roughly understood as a truncated histogram of the `depth` last (in the time meaning) greatest riped up elements.

The loop detector keep track of the `depth` TrackElement with the greatest processing count. TrackElement are just identified through the `id` of their associated AutoSegment. Each entry in the loop table contains:

- The `id` of the associated TrackSegment (Katabatic::AutoSegment).
- The `count` of times it has been processed
- The `timestamp` of the latest time it has been updated.

The table (implemented as `vector<>`) it kept sorted on the timestamp (decreasing). Whenever there is more than `depth` elements in the table, the oldest one are discarted (regardless of their count). Obviously, there are pathological cases into which a loop cannot be detected, but so far it has not happened so a more robust approach seems not necessary at this time.

Whenever the count of an element reaches `countLimit`, the looping flag is set. It will remains set unless the faulty element is manually removed.

## Constructor & Destructor Documentation

## ◆ RoutingEventLoop()

RoutingEventLoop | ( | size_t | depth = `10`,
|  | int | countLimit = `20`
| ) |  |

Construct a loop detector that handle `depth` differents segments and has a looping threshold of `countLimit`.

## Member Function Documentation

## ◆ isLooping()

bool isLooping | ( |  | ) | const

inline

Returns: true if the loop threshold has been reached for at least one element.

Referenced by RoutingEvent::process().

## ◆ getMaxCount()

int getMaxCount | ( |  | ) | const

inline

The maximal count an element as reached so far.

Referenced by RoutingEvent::process().

## ◆ getElements()

const std::vector< Element > & getElements | ( |  | ) | const

inline

The complete table elements.

Referenced by RoutingEvent::process().

## ◆ update()

void update | ( | size_t | id | ) |

Update the loop, telling that element `id` has appreared one more time.

Referenced by RoutingEvent::process().

## ◆ erase()

void erase | ( | size_t | id | ) |

Remove the entry related to element `id` in the table. The state of the table is fully recomputed after the removal (looping flag & maximum count).

This method is used when a loop has been encountered, presumably on element `id`, and we want to continue. To avoid the loop detector yelling at each check, the associated TrackElement should be invalidated and it's reference removed from the table.

Referenced by RoutingEvent::process().

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

- RoutingEventLoop.h
- RoutingEventLoop.cpp
- RoutingEventLoop.dox