![]() |
|
|||
0001 /** 0002 * @brief Emulated message queue. Based on UNIX Network Programming 0003 * Volume 2 Second Edition interprocess Communications by W. Richard Stevens 0004 * book. This code is only used for MacOS, as there aren't any reasonable 0005 * queues available. 0006 * 0007 * @file sys_emqueue.h 0008 */ 0009 /* ----------------------------------------------------------------------------- 0010 * Enduro/X Middleware Platform for Distributed Transaction Processing 0011 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0012 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0013 * This software is released under one of the following licenses: 0014 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0015 * See LICENSE file for full text. 0016 * ----------------------------------------------------------------------------- 0017 * AGPL license: 0018 * 0019 * This program is free software; you can redistribute it and/or modify it under 0020 * the terms of the GNU Affero General Public License, version 3 as published 0021 * by the Free Software Foundation; 0022 * 0023 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0024 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0025 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0026 * for more details. 0027 * 0028 * You should have received a copy of the GNU Affero General Public License along 0029 * with this program; if not, write to the Free Software Foundation, Inc., 0030 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0031 * 0032 * ----------------------------------------------------------------------------- 0033 * A commercial use license is available from Mavimax, Ltd 0034 * contact@mavimax.com 0035 * ----------------------------------------------------------------------------- 0036 */ 0037 #ifndef __sys_emqueue_h 0038 #define __sys_emqueue_h 0039 0040 /*---------------------------Includes-----------------------------------*/ 0041 #include <ndrx_config.h> 0042 #include <pthread.h> 0043 #include <unistd.h> 0044 #include <sys/signal.h> 0045 #include <time.h> 0046 /*---------------------------Externs------------------------------------*/ 0047 /*---------------------------Macros-------------------------------------*/ 0048 0049 /* size of message in file is rounded up for alignment */ 0050 #define NDRX_EMQ_MSGSIZE(i) ((((i) + sizeof(long)-1) / sizeof(long)) * sizeof(long)) 0051 0052 /*---------------------------Enums--------------------------------------*/ 0053 /*---------------------------Typedefs-----------------------------------*/ 0054 0055 /** 0056 * opaque interface 0057 */ 0058 typedef struct emq_info *mqd_t; 0059 0060 /** 0061 * Queue attributes definition 0062 */ 0063 struct mq_attr 0064 { 0065 long mq_flags; /**< MQ flags */ 0066 long mq_maxmsg; /**< max messages per queue */ 0067 long mq_msgsize; /**< max message size in bytes */ 0068 long mq_curmsgs; /**< number of messages in queue */ 0069 }; 0070 0071 /** 0072 * Message queue header 0073 */ 0074 struct emq_hdr 0075 { 0076 struct mq_attr emqh_attr; /**< queue attributes */ 0077 long emqh_head; /**< first message index */ 0078 long emqh_free; /**< first free message index */ 0079 long emqh_nwait; /**< number of threads waiting */ 0080 pid_t emqh_pid; /**< notification pid */ 0081 struct sigevent emqh_event; /**< for emq_notify() */ 0082 pthread_mutex_t emqh_lock; /**< mutex lock */ 0083 pthread_cond_t emqh_wait; /**< condition var */ 0084 }; 0085 0086 /** 0087 * Message header 0088 **/ 0089 struct emq_msg_hdr 0090 { 0091 long msg_next; /**< next msg index */ 0092 ssize_t msg_len; /**< actual length */ 0093 unsigned int msg_prio; /**< priority */ 0094 }; 0095 0096 /** 0097 * Process mapped memory for queue 0098 */ 0099 struct emq_info 0100 { 0101 0102 struct emq_hdr *emqi_hdr; /**< mapped memory */ 0103 int emqi_flags; /**< flags for this process */ 0104 }; 0105 0106 /*---------------------------Globals------------------------------------*/ 0107 /*---------------------------Statics------------------------------------*/ 0108 /*---------------------------Prototypes---------------------------------*/ 0109 0110 extern NDRX_API int emq_close(mqd_t); 0111 extern NDRX_API int emq_getattr(mqd_t, struct mq_attr *); 0112 extern NDRX_API int emq_notify(mqd_t, const struct sigevent *); 0113 extern NDRX_API mqd_t emq_open(const char *, int, ...); 0114 extern NDRX_API ssize_t emq_receive(mqd_t, char *, size_t, unsigned int *); 0115 extern NDRX_API int emq_send(mqd_t, const char *, size_t, unsigned int); 0116 extern NDRX_API int emq_setattr(mqd_t, const struct mq_attr *, struct mq_attr *); 0117 extern NDRX_API int emq_unlink(const char *name); 0118 0119 extern NDRX_API int emq_timedsend(mqd_t emqd, const char *ptr, size_t len, unsigned int prio, 0120 const struct timespec *__abs_timeout); 0121 0122 extern NDRX_API ssize_t emq_timedreceive(mqd_t emqd, char *ptr, size_t maxlen, unsigned int *priop, 0123 const struct timespec * __abs_timeout); 0124 0125 #endif 0126 0127 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |