File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,7 @@ void CUDTGroup::GroupContainer::erase(CUDTGroup::gli_t it)
335335 }
336336 }
337337 m_List.erase (it);
338+ --m_SizeCache;
338339}
339340
340341void CUDTGroup::setOpt (SRT_SOCKOPT optName, const void * optval, int optlen)
Original file line number Diff line number Diff line change @@ -406,16 +406,21 @@ class CUDTGroup
406406 SRTSOCKET m_PeerGroupID;
407407 struct GroupContainer
408408 {
409- std::list<SocketData> m_List;
409+ private:
410+ std::list<SocketData> m_List;
411+ sync::atomic<size_t > m_SizeCache;
410412
411413 // / This field is used only by some types of groups that need
412414 // / to keep track as to which link was lately used. Note that
413415 // / by removal of a node from the m_List container, this link
414416 // / must be appropriately reset.
415417 gli_t m_LastActiveLink;
416418
419+ public:
420+
417421 GroupContainer ()
418- : m_LastActiveLink(m_List.end())
422+ : m_SizeCache(0 )
423+ , m_LastActiveLink(m_List.end())
419424 {
420425 }
421426
@@ -425,13 +430,14 @@ class CUDTGroup
425430 gli_t begin () { return m_List.begin (); }
426431 gli_t end () { return m_List.end (); }
427432 bool empty () { return m_List.empty (); }
428- void push_back (const SocketData& data) { m_List.push_back (data); }
433+ void push_back (const SocketData& data) { m_List.push_back (data); ++m_SizeCache; }
429434 void clear ()
430435 {
431436 m_LastActiveLink = end ();
432437 m_List.clear ();
438+ m_SizeCache = 0 ;
433439 }
434- size_t size () { return m_List. size () ; }
440+ size_t size () { return m_SizeCache ; }
435441
436442 void erase (gli_t it);
437443 };
You can’t perform that action at this time.
0 commit comments