//  Beta release only.
//
//  Copyright(c) Ivyware Pty Ltd 2002-6  (all rights reserved)
//               MELBOURNE, VICTORIA, AUSTRALIA, 3130
//
//  Provided no fee is charged (either by the distributer or user)
//  permission to use, copy, modify, and distribute this software and
//  its documentation for any purpose and without fee is hereby granted,
//  provided that the above copyright notice appear in all copies and
//  that both that copyright notice and this permission notice appear
//  in supporting documentation.
//
//  No waranty or suitablity for purpose is implied.
//
//
//  P2Peer message queue definitions and prototypes
//  NOTES: Observes assigned P2PeerMsg priority.  Highest priority
//         P2PeerMsg's are removed from the queue first regardless
//         of the order appended to the queue
//

#pragma once

#ifndef NO_DEBUG_NEW
#define new DEBUG_NEW
#endif

#include "P2PeerMsg.h"

//
//
//  P2Peer message queue object
//  NOTES: Used to manage queues of P2PeerMsg's.
//       : Thread safe implementation.
//
class P2PmsgKERNEL_EXT P2PeerMsgQue
{
      void
        RenderQueSafe ( );

    // Constructors and destructor
    public:
        P2PeerMsgQue ( HANDLE hNotnEvent );
      virtual
       ~P2PeerMsgQue ( );

    // Operations
    public:
      P2PeerMsg*
        Append   ( P2PeerMsg *pMsg );
      int
        Append   ( P2PeerMsg& oMsg );
      P2PeerMsg*
        Preppend ( P2PeerMsg *pMsg );
      P2PeerMsg*
        Remove   ( );

    // Utilities
    public:
      void
        Flush ( );

    // Property management
    public:
      int
        GetCount ( );
      bool
        IsEmpty  ( );
      HANDLE
        GetEvent ( );

    // Attributes
    private:
      HANDLE           m_hThreadPump;
      HANDLE           m_hNotnEvent;
      CRITICAL_SECTION m_oCSectionQue;

      CListP2PeerMsg   m_oCListP2PeerMsg;
};


