Click here to Skip to main content
15,896,153 members
Articles / General Programming / Threads

A Standard Multi-threaded Dynamic Queue

Rate me:
Please Sign up or sign in to vote.
4.79/5 (24 votes)
28 Oct 2010GPL36 min read 152.2K   5.6K   111  
This is a standard Windows / C++ implementation of a multi-threaded queue.
#ifndef SIMPLEMESSAGE_H
#define SIMPLEMESSAGE_H

// This class implements the simple objects that
// are passed via the queues in between the threads.

class CSimpleMessage
{
public:
   CSimpleMessage(void)
   {
      m_nID = 0;
      m_szMessage = _T("No Message");
   }
   CSimpleMessage(unsigned int nID)
   {
      m_nID = nID;
      m_szMessage = _T("No Message");
   }
   virtual ~CSimpleMessage(void) { }

private:
   unsigned int m_nID;
   CString m_szMessage;

public:
   void SetId(unsigned int nID) { m_nID = nID; };
   unsigned int GetId() { return m_nID; };
   void SetMsg(CString szMsg) { m_szMessage = szMsg; };
   CString GetMsg() { return m_szMessage; };
};

#endif  // ! defined (SIMPLEMESSAGE_H)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Italy Italy
Senior Software Developer in C/C++ and Oracle.
Ex-physicist holding a Ph.D. on x-ray lasers.

Comments and Discussions