LCOV - code coverage report
Current view: top level - ifmap - ifmap_update_queue.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 1 1 100.0 %
Date: 2026-11-09 02:10:49 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __ctrlplane__ifmap_update_queue__
       7             : #define __ctrlplane__ifmap_update_queue__
       8             : 
       9             : #include <map>
      10             : #include "ifmap/ifmap_update.h"
      11             : 
      12             : class IFMapServer;
      13             : 
      14             : class IFMapUpdateQueue {
      15             : public:
      16             :     typedef boost::intrusive::member_hook<
      17             :         IFMapListEntry,
      18             :         boost::intrusive::list_member_hook<>,
      19             :         &IFMapListEntry::node
      20             :     > MemberHook;
      21             :     typedef boost::intrusive::list<IFMapListEntry, MemberHook> List;
      22             : 
      23             :     typedef std::map<int, IFMapMarker *> MarkerMap;
      24             : 
      25             :     explicit IFMapUpdateQueue(IFMapServer *server);
      26             : 
      27             :     ~IFMapUpdateQueue();
      28             : 
      29             :     // Called from the Exporter to add a new update at the tail of the queue.
      30             :     // Returns true if the tail_marker was the last element in the queue.
      31             :     bool Enqueue(IFMapUpdate *update);
      32             : 
      33             :     // Called from the Exporter to remove an update (because it is going to
      34             :     // be superceeded) or by the Sender when the update advertise mask is
      35             :     // empty.
      36             :     void Dequeue(IFMapUpdate *update);
      37             : 
      38             :     // Called by the Sender to iterate through the update queue. Current can
      39             :     // be a marker or the previous update.
      40             :     IFMapListEntry *Next(IFMapListEntry *current);
      41             : 
      42             :     // Returns the element before current or NULL if current is the first
      43             :     // element in the list.
      44             :     IFMapListEntry *Previous(IFMapListEntry *current);
      45             : 
      46             :     // Returns the last element in the list or NULL if the list is empty.
      47             :     IFMapListEntry *GetLast();
      48             : 
      49             :     // Moves the marker from its previous position to the position immediately
      50             :     // 'before' the current node. Used when the Sender stops sending updates or
      51             :     // is blocked.
      52             :     void MoveMarkerBefore(IFMapMarker *marker, IFMapListEntry *current);
      53             : 
      54             :     // Moves the marker from its previous position to the position immediately
      55             :     // 'after' the current node. Used when the Sender stops sending updates or
      56             :     // is blocked.
      57             :     void MoveMarkerAfter(IFMapMarker *marker, IFMapListEntry *current);
      58             : 
      59             :     // Removes a set of members from marker, creates a new marker with this set
      60             :     // and inserts it 'before' current. Returns the new marker.
      61             :     IFMapMarker* MarkerSplitBefore(IFMapMarker *marker, IFMapListEntry *current,
      62             :                                    const BitSet &msplit);
      63             : 
      64             :     // Removes a set of members from marker, creates a new marker with this set
      65             :     // and inserts it 'after' current. Returns the new marker.
      66             :     IFMapMarker *MarkerSplitAfter(IFMapMarker *marker, IFMapListEntry *current,
      67             :                                   const BitSet &msplit);
      68             : 
      69             :     // Moves the specified 'mmove' set from 'src' to 'dst'. If 'src' becomes
      70             :     // empty it is deleted.
      71             :     void MarkerMerge(IFMapMarker *dst, IFMapMarker *src, const BitSet &mmove);
      72             : 
      73             :     // When a new client is established, adds it to the tail marker in order
      74             :     // to receive new updates.
      75             :     void Join(int bit);
      76             : 
      77             :     // When a client session terminate, removes its bit from all the queue
      78             :     // entries (marker or otherwise).
      79             :     void Leave(int bit);
      80             : 
      81             :     // Retrieves the marker corresponding to the client that has the specified
      82             :     // index.
      83             :     IFMapMarker *GetMarker(int bit);
      84             : 
      85             :     // Returns true if the queue is empty.
      86             :     bool empty() const;
      87             : 
      88        1510 :     IFMapMarker *tail_marker() { return &tail_marker_; }
      89             : 
      90             :     int size() const;
      91             : 
      92             :     void PrintQueue();
      93             : 
      94             : private:
      95             :     friend class ShowIFMapUpdateQueue;
      96             :     static const uint64_t NULL_SEQUENCE = 0;
      97             :     List list_;
      98             :     MarkerMap marker_map_;
      99             :     IFMapMarker tail_marker_;
     100             :     IFMapServer *server_;
     101             :     uint64_t sequence_;
     102             : 
     103             :     void SetSequence(IFMapListEntry *item);
     104             :     void PushbackIntoList(IFMapListEntry *item);
     105             :     void InsertIntoListBefore(IFMapListEntry *ptr, IFMapListEntry *item);
     106             :     void InsertIntoListAfter(IFMapListEntry *ptr, IFMapListEntry *item);
     107             :     void EraseFromList(IFMapListEntry *item);
     108             :     void ClearAndDisposeList();
     109             :     IFMapMarker* MarkerSplit(IFMapMarker *marker, IFMapListEntry *current,
     110             :                              const BitSet &msplit, bool before);
     111             : };
     112             : 
     113             : #endif /* defined(__ctrlplane__ifmap_update_queue__) */

Generated by: LCOV version 1.14