mq.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:3k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.4 $
- * $Date: 1998/05/19 18:16:23 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996,97 Lucent Technologies //
- // All Rights Reserved //
- // //
- // THIS IS UNPUBLISHED //
- // PROPRIETARY SOURCE //
- // CODE OF Lucent Technologies //
- // AND elemedia //
- // //
- ////////////////////////////////////////////////////////////////
- //
- ////////////////////////////////////////////////////////////////
- // Example programs are provided soley to demonstrate one //
- // possible use of the stack libraries and are included for //
- // instructional purposes only. You are free to use, modify //
- // and/or redistribute any portion of code in the example //
- // programs. However, such examples are not intended to //
- // represent production quality code. //
- // //
- // THE COPYRIGHT HOLDERS PROVIDE THESE EXAMPLE PROGRAMS //
- // "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED //
- // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED //
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A //
- // PARTICULAR PURPOSE. //
- ////////////////////////////////////////////////////////////////
- #if !defined(__MQ_H__)
- #define __MQ_H__
- #if (defined(WIN32))
- #include <windows.h>
- #elif defined(VXWORKS)
- #include "vxWorks.h"
- #include "taskLib.h"
- #include "semLib.h"
- #include "selectLib.h"
- #include "fcntl.h"
- #include "sockLib.h"
- #include "inetLib.h"
- #include "msgQLib.h"
- #else
- #if (defined(__hpux))
- #include <pthread.h>
- #else
- #include <thread.h>
- #include <synch.h>
- #endif
- #endif
- #if (defined(WIN32))
- #include <windows.h>
- #endif
- struct USER_MESSAGE
- {
- int message;
- int wParam;
- int lParam;
- };
- class MessageQueue
- {
- public:
- MessageQueue(char *name, int mqlen, unsigned long param);
- virtual ~MessageQueue();
- void QueueMessage(USER_MESSAGE *msg);
- int DequeueMessage(USER_MESSAGE *msg);
- // Start listener thread.
- int Start();
- // Stop listener thread.
- void Stop();
- virtual void NotifyMessage(USER_MESSAGE&) = 0;
- protected:
- void wait_for_message();
- struct mqueue_node
- {
- USER_MESSAGE msg;
- mqueue_node *next;
- } *mqueue_head, *mqueue_tail;
- int q_len;
- char q_name[80];
- #if defined(WIN32)
- unsigned long thread_id;
- HANDLE thread_handle;
- static unsigned __stdcall _boot(void *context);
- #elif defined(VXWORKS)
- MSG_Q_ID mqueue_id;
- int thread_id;
- SEM_ID thread_exited_flag;
- static int _boot(void *context);
- #elif (defined(__hpux))
- pthread_mutex_t mutex;
- pthread_cond_t mqueue_not_empty;
- pthread_t thread_id;
- static void *_boot(void *context);
- #else
- mutex_t mutex;
- cond_t mqueue_not_empty;
- thread_t thread_id;
- static void *_boot(void *context);
- #endif
- };
- #if (defined(WIN32))
- #define USER_MESSAGE_ID (WM_USER + 1001)
- #else
- #define WM_USER 100
- #endif
- #define MQ_INTERNAL_ID WM_USER + 100
- #endif