android 消息队列如何使用

flydream0
博客专家认证
2012-02-23 11:22:19
在Android源码路径:system/core/include/cutils/下有个mq.h头文件,这里边是一些消息队列的接口.
内容如下:
#ifndef __MQ_H
#define __MQ_H

#ifdef __cplusplus
extern "C" {
#endif

/** A message. */
typedef struct MqMessage MqMessage;

/** A destination to which messages can be sent. */
typedef struct MqDestination MqDestination;

/* Array of bytes. */
typedef struct MqBytes MqBytes;

/**
* Hears messages.
*
* @param destination to which the message was sent
* @param message the message to hear
*/
typedef void MqMessageListener(MqDestination* destination, MqMessage* message);

/**
* Hears a destination close.
*
* @param destination that closed
*/
typedef void MqCloseListener(MqDestination* destination);

/** Message functions. */

/**
* Creates a new Message.
*
* @param header as defined by user
* @param body as defined by user
* @param replyTo destination to which replies should be sent, NULL if none
*/
MqMessage* mqCreateMessage(MqBytes header, MqBytes body,
MqDestination* replyTo);

/** Sends a message to a destination. */
void mqSendMessage(MqMessage* message, MqDestination* destination);

/** Destination functions. */

/**
* Creates a new destination. Acquires a reference implicitly.
*
* @param messageListener function to call when a message is recieved
* @param closeListener function to call when the destination closes
* @param userData user-specific data to associate with the destination.
* Retrieve using mqGetDestinationUserData().
*/
MqDestination* mqCreateDestination(MqMessageListener* messageListener,
MqCloseListener* closeListener, void* userData);

/**
* Gets user data which was associated with the given destination at
* construction time.
*
* It is only valid to call this function in the same process that the
* given destination was created in.
* This function returns a null pointer if you call it on a destination
* created in a remote process.
.....
我想知道的是如何在Android源码开发模式下使用该头文件提供的消息队列接口?编译链接时需要注意什么?
另:我比较奇怪的是,在这个头文件中没有struct MqMessage的定义,那么这个结构是在哪定义的?
...全文
230 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
flydream0 2012-02-23
  • 打赏
  • 举报
回复
顶起,哪位兄台给点相关资料也行,最好有源码示例。

80,352

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧