PiImageStreamer
Loading...
Searching...
No Matches
SWE4211RPi::NetworkTransmissionManager Class Reference
Inheritance diagram for SWE4211RPi::NetworkTransmissionManager:
Collaboration diagram for SWE4211RPi::NetworkTransmissionManager:

Public Member Functions

 NetworkTransmissionManager (NetworkManager &associatedReceptionManager, std::string threadName)
 
virtual ~NetworkTransmissionManager ()
 
void enqueueMessage (networkMessageStruct &itemToEnqueue)
 
void stopThreadExecution ()
 
virtual void run ()
 
- Public Member Functions inherited from SWE4211RPi::RunnableClass
 RunnableClass (std::string threadName, int priority=0)
 
virtual ~RunnableClass ()
 
virtual void resetThreadDiagnostics ()
 
virtual void printInformation ()
 
virtual double getCPUUsageInfo ()
 
virtual pid_t getThreadID ()
 
virtual void start () final
 
virtual void setPriority (int priority) final
 
virtual int getPriority () final
 
virtual bool isShutdown () final
 
virtual bool isStarted () final
 
virtual void waitForShutdown ()
 

Private Attributes

NetworkManager & associatedReceptionManager
 
std::queue< networkMessageStruct > transmissionQueue
 
sem_t queueCountSemaphore
 
std::mutex queueMutex
 
std::atomic_int_fast32_t mcount = {0}
 

Additional Inherited Members

- Static Public Member Functions inherited from SWE4211RPi::RunnableClass
static void printThreads ()
 
static void resetAllThreadInformation ()
 
- Protected Member Functions inherited from SWE4211RPi::RunnableClass
virtual void startChildRunnables ()
 
virtual void stopChildRunnables ()
 
- Protected Attributes inherited from SWE4211RPi::RunnableClass
std::thread * myThread = NULL
 
pthread_t executingThread = 0
 
pid_t myOSThreadID = 0
 
std::string myName
 
std::atomic< bool > keepGoing {true}
 
std::atomic< bool > runCompleted {false}
 
std::atomic< bool > runStarted {false}
 
int priority = -1
 
- Static Protected Attributes inherited from SWE4211RPi::RunnableClass
static std::list< RunnableClass * > runningThreads
 

Constructor & Destructor Documentation

◆ NetworkTransmissionManager()

NetworkTransmissionManager::NetworkTransmissionManager ( NetworkManager &  associatedReceptionManager,
std::string  threadName 
)

Initialize the semaphore to be a counting sem with nothing on it.

◆ ~NetworkTransmissionManager()

NetworkTransmissionManager::~NetworkTransmissionManager ( )
virtual

Nothing is needed here for now, as there is nothing dynamically created that we need to clean up afterwards.

Member Function Documentation

◆ enqueueMessage()

void NetworkTransmissionManager::enqueueMessage ( networkMessageStruct &  itemToEnqueue)
  1. Lock the queue.

  2. Place the given item on the end of the queue.

  3. Indicate that something has been enqueued through the semaphore.

Here is the caller graph for this function:

◆ run()

void NetworkTransmissionManager::run ( )
virtual

This is the virtual run method. It will execute the given code that is to be executed by this class.

  1. While the thread is to keep running.

    115

  2. Block if there is nothing on the queue until something is enqueued.

  3. Lock the queue and dequeue an item from it.

  4. Obtain the first item from the queue and then dispose of it.

  5. Set the security mode to 0 and the id to the message count. Then increment message count.

  6. Set the timestamp for the message.

Implements SWE4211RPi::RunnableClass.

Here is the call graph for this function:

◆ stopThreadExecution()

void NetworkTransmissionManager::stopThreadExecution ( )
virtual

This method will override the default stop method. In doing so, it must call the base class's stop method prior to invoking it's own logic.

  1. Call the parent's stop method.

  2. Enqueue a message that is an end message

Reimplemented from SWE4211RPi::RunnableClass.

Here is the call graph for this function:

Member Data Documentation

◆ mcount

std::atomic_int_fast32_t SWE4211RPi::NetworkTransmissionManager::mcount = {0}
private

This keeps track of how many messages have been sent. It is the message count.

◆ queueCountSemaphore

sem_t SWE4211RPi::NetworkTransmissionManager::queueCountSemaphore
private

This is a counting semaphore which keeps track of how many items are on the queue.

◆ queueMutex

std::mutex SWE4211RPi::NetworkTransmissionManager::queueMutex
private

This is a mutex for the class which is used to lock critical sections in different methods.


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