Created
March 10, 2015 01:53
-
-
Save eventhelix/470a9c3cc7e31f1adfea to your computer and use it in GitHub Desktop.
Overworked Message Handler class and a simple Get-Set DSP class http://www.eventhelix.com/realtimemantra/object_oriented/object_design_tips_2.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DSP | |
{ | |
public: | |
Queue *GetWriteBufferQueue(); | |
Queue *GetReadBufferQueue(); | |
void SetStatusRegister(int mask); | |
void SetCongestionLevel(); | |
void SetWriteBufferQueue(Buffer *pQueue); | |
void SetReadBufferQueue(Buffer *pQueue); | |
}; | |
Status MessageHandler::SendMessage(Buffer *pBuffer) | |
{ | |
int dspId = pBuffer->GetDSP(); | |
DSP* pDSP = m_dsp[dspId]; | |
Queue *pQueue = pDSP->GetWriteBufferQueue(); | |
int status = pQueue->Add(pBuffer); | |
pDSP->SetStatusRegister(WRITTEN_MESSAGE); | |
if (pQueue->GetLength() > CONGESTION_THRESHOLD) | |
{ | |
pDSP->SetCongestionLevel(); | |
} | |
return status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment