4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999,2001 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See devlib/README for information.
9 * \brief Simple inter-process messaging system
11 * This module implements a common system for executing
12 * a user defined action calling a hook function.
16 * \author Bernardo Innocenti <bernie@develer.com>
21 *#* Revision 1.3 2004/08/25 14:12:09 rasky
22 *#* Aggiornato il comment block dei log RCS
24 *#* Revision 1.2 2004/08/14 19:37:57 rasky
25 *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
27 *#* Revision 1.1 2004/06/06 15:11:08 bernie
28 *#* Import into DevLib.
35 #include <mware/list.h>
38 typedef struct MsgPort
40 List queue; /*!< Messages queued at this port */
41 Event evn; /*!< Event to trigger when a message arrives */
47 Node link; /*!< Link into message port queue */
48 MsgPort *replyPort; /*!< Port to which the msg is to be replied */
49 /* User data may follow */
53 /*! Initialize a message port */
54 INLINE void msg_initPort(MsgPort* port, Event event)
56 INITLIST(&port->queue);
60 /*! Queue \a msg into \a port, triggering the associated event */
61 INLINE void msg_put(MsgPort* port, Msg* msg)
63 ADDTAIL(&port->queue, &msg->link);
67 /* Get the first message from the queue of \a port, or NULL if the port is empty */
68 INLINE Msg* msg_get(MsgPort* port)
70 return (Msg*)REMHEAD(&port->queue);
73 /*! Send back (reply) \a msg to its sender */
74 INLINE void msg_reply(Msg* msg)
76 msg_put(msg->replyPort, msg);
79 #endif /* KERN_MSG_H */