在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的定义,那么这个结构是在哪定义的?
内容如下:
#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的定义,那么这个结构是在哪定义的?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货