Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::MPLastInFirstOut Class Reference

Thread safe class that manages a last in first out singly linked list. More...

Inheritance diagram for Burger::MPLastInFirstOut:
Inheritance graph
[legend]
Collaboration diagram for Burger::MPLastInFirstOut:
Collaboration graph
[legend]

Public Member Functions

 MPLastInFirstOut () noexcept
 Default constructor.
 
 MPLastInFirstOut (ForwardLink *pRoot) noexcept
 Default constructor.
 
void clear (void) noexcept
 Discard the linked list.
 
uint_t is_empty (void) const noexcept
 Default constructor.
 
uintptr_t size (void) noexcept
 Count the number of entries in this linked list.
 
void add_first (ForwardLink *pNewRoot) noexcept
 Insert an entry to the head of the list.
 
void add_last (ForwardLink *pNewTail) noexcept
 Insert an entry to the end of the list.
 
ForwardLinkremove_first (void) noexcept
 Remove an entry from the head of the list.
 
ForwardLinktake_list (void) noexcept
 Assigns ownership of the linked list.
 
eError remove (ForwardLink *pEntry) noexcept
 Remove an item from the linked list.
 
void reverse_list (void) noexcept
 Reverse the singly linked list.
 
void lock (void) noexcept
 Lock the singly linked list.
 
void unlock (void) noexcept
 Unlock the singly linked list.
 

Protected Attributes

Mutex m_Lock
 Critical section for thread safety.
 
- Protected Attributes inherited from Burger::LastInFirstOut
ForwardLinkm_pRoot
 Root pointer to the singly linked list.
 

Private Member Functions

 MPLastInFirstOut (const MPLastInFirstOut &)=delete
 
MPLastInFirstOutoperator= (const MPLastInFirstOut &)=delete
 
 MPLastInFirstOut (MPLastInFirstOut &&)=delete
 
MPLastInFirstOutoperator= (MPLastInFirstOut &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from Burger::LastInFirstOut
 LastInFirstOut () noexcept
 Default constructor.
 
 LastInFirstOut (ForwardLink *pRoot) noexcept
 Default constructor.
 
void clear (void) noexcept
 Discard the linked list.
 
uint_t is_empty (void) const noexcept
 Default constructor.
 
ForwardLinkget_root (void) const noexcept
 Get the head of the list.
 
uintptr_t size (void) const noexcept
 Count the number of entries in this linked list.
 
void add_first (ForwardLink *pNewRoot) noexcept
 Insert an entry to the head of the list.
 
void add_last (ForwardLink *pNewTail) noexcept
 Insert an entry to the end of the list.
 
ForwardLinkremove_first (void) noexcept
 Remove an entry from the head of the list.
 
ForwardLinktake_list (void) noexcept
 Assigns ownership of the linked list.
 
eError remove (ForwardLink *pEntry) noexcept
 Remove an item from the linked list.
 
void reverse_list (void) noexcept
 Reverse the singly linked list.
 

Detailed Description

Thread safe class that manages a last in first out singly linked list.


This class holds a linked list that is treated as a last in first out stack with a Mutex to ensure thread safety.

See also
LastInFirstOut

Constructor & Destructor Documentation

◆ MPLastInFirstOut() [1/4]

Burger::MPLastInFirstOut::MPLastInFirstOut ( const MPLastInFirstOut & )
privatedelete

◆ MPLastInFirstOut() [2/4]

Burger::MPLastInFirstOut::MPLastInFirstOut ( MPLastInFirstOut && )
privatedelete

◆ MPLastInFirstOut() [3/4]

Burger::MPLastInFirstOut::MPLastInFirstOut ( )
noexcept

Default constructor.


Construct the class with an empty list

See also
MPLastInFirstOut(ForwardLink *)

◆ MPLastInFirstOut() [4/4]

Burger::MPLastInFirstOut::MPLastInFirstOut ( ForwardLink * pRoot)
noexcept

Default constructor.


Construct the class with an supplied list

Parameters
pRootPointer to the linked list to initialize this class with
See also
MPLastInFirstOut()

Member Function Documentation

◆ add_first()

void BURGER_API Burger::MPLastInFirstOut::add_first ( ForwardLink * pNewRoot)
noexcept

Insert an entry to the head of the list.


Insert a linked list into the head of the stored linked list.

Parameters
pNewRootPointer to the new head of the list
See also
add_last(ForwardLink *) or remove_first(void)

◆ add_last()

void BURGER_API Burger::MPLastInFirstOut::add_last ( ForwardLink * pNewTail)
noexcept

Insert an entry to the end of the list.


Insert a linked list into the tail of the stored linked list.

Parameters
pNewTailPointer to the list that will be appended to the current linked list
See also
add_first(ForwardLink *)

◆ clear()

void BURGER_API Burger::MPLastInFirstOut::clear ( void )
noexcept

Discard the linked list.


Set the root pointer to nullptr. No deallocations are performed.

◆ is_empty()

Burger::MPLastInFirstOut::is_empty ( void ) const
inlinenoexcept

Default constructor.


Returns
TRUE if there are entries in the linked list.
See also
clear(void)

◆ lock()

Burger::MPLastInFirstOut::lock ( void )
inlinenoexcept

Lock the singly linked list.


Obtain the lock on the Mutex so that the application can traverse or otherwise manipulate the linked list.

See also
Burger::MPLastInFirstOut::unlock(void)

◆ operator=() [1/2]

MPLastInFirstOut & Burger::MPLastInFirstOut::operator= ( const MPLastInFirstOut & )
privatedelete

◆ operator=() [2/2]

MPLastInFirstOut & Burger::MPLastInFirstOut::operator= ( MPLastInFirstOut && )
privatedelete

◆ remove()

Burger::eError BURGER_API Burger::MPLastInFirstOut::remove ( ForwardLink * pEntry)
noexcept

Remove an item from the linked list.


Traverse the linked list until the pointer is found and then unlink it from the list. The pointer is not deleted, just unlinked.

Parameters
pEntryItem to remove from the linked list
Returns
Zero on success, kErrorItemNotFound if the pointer wasn't in the list

◆ remove_first()

Burger::ForwardLink *BURGER_API Burger::MPLastInFirstOut::remove_first ( void )
noexcept

Remove an entry from the head of the list.


Remove the pointer from the root of the linked list. Sets the new root with the second entry of the linked list if there is a second entry.

Returns
The unlinked head pointer or nullptr if the list was empty.
See also
add_first(ForwardLink *)

◆ reverse_list()

void BURGER_API Burger::MPLastInFirstOut::reverse_list ( void )
noexcept

Reverse the singly linked list.


Traverse the singly linked list and reverse the linkage so that the order of the entries are in the opposite order.

See also
Burger::reverse_list(ForwardLink *)

◆ size()

uintptr_t BURGER_API Burger::MPLastInFirstOut::size ( void )
noexcept

Count the number of entries in this linked list.


Traverse the linked list until the end is reached and return the number of entries found.

Returns
The number of elements in this linked list, can be zero.
See also
is_empty(void) const

◆ take_list()

Burger::ForwardLink *BURGER_API Burger::MPLastInFirstOut::take_list ( void )
noexcept

Assigns ownership of the linked list.


Returns the head pointer of the linked list and sets the linked list in this class to being empty. The calling function is assigned ownership of the entire list.

Returns
The pointer to the entire linked list or nullptr if the list was empty.
See also
clear(void)

◆ unlock()

Burger::MPLastInFirstOut::unlock ( void )
inlinenoexcept

Unlock the singly linked list.


Release the lock on the Mutex so that the linked list can be used by other threads.

See also
Burger::MPLastInFirstOut::lock(void)

Member Data Documentation

◆ m_Lock

Mutex Burger::MPLastInFirstOut::m_Lock
protected

Critical section for thread safety.