gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37949 - gnunet/src/include


From: gnunet
Subject: [GNUnet-SVN] r37949 - gnunet/src/include
Date: Mon, 19 Sep 2016 16:37:08 +0200

Author: grothoff
Date: 2016-09-19 16:37:07 +0200 (Mon, 19 Sep 2016)
New Revision: 37949

Added:
   gnunet/src/include/gnunet_nc_lib.h
Log:
header for new NC logic

Added: gnunet/src/include/gnunet_nc_lib.h
===================================================================
--- gnunet/src/include/gnunet_nc_lib.h                          (rev 0)
+++ gnunet/src/include/gnunet_nc_lib.h  2016-09-19 14:37:07 UTC (rev 37949)
@@ -0,0 +1,101 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2012-2016 GNUnet e.V.
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @author Christian Grothoff
+ *
+ * @file
+ * General-purpose broadcast mechanism for message queues
+ *
+ * @defgroup mq  NC library
+ * General-purpose broadcast mechanism for message queues
+ *
+ * @see [Documentation](https://gnunet.org/nc)
+ *
+ * @{
+ */
+#ifndef GNUNET_NC_H
+#define GNUNET_NC_H
+
+
+/**
+ * The notification context is the key datastructure for a convenience
+ * API used for transmission of notifications to the subscriber until the
+ * subscriber disconnects (or the notification context is destroyed, in
+ * which case we disconnect these subscribers).  Essentially, all
+ * (notification) messages are queued up until the subscriber is able to
+ * read them.
+ */
+struct GNUNET_NotificationContext;
+
+
+/**
+ * Create a new notification context.
+ *
+ * @param queue_length maximum number of messages to keep in
+ *        the notification queue; optional messages are dropped
+ *        if the queue gets longer than this number of messages
+ * @return handle to the notification context
+ */
+struct GNUNET_NotificationContext *
+GNUNET_notification_context_create (unsigned int queue_length);
+
+
+/**
+ * Destroy the context, force disconnect for all subscribers.
+ *
+ * @param nc context to destroy.
+ */
+void
+GNUNET_notification_context_destroy (struct GNUNET_NotificationContext *nc);
+
+
+/**
+ * Add a subscriber to the notification context.
+ *
+ * @param nc context to modify
+ * @param mq message queue add
+ */
+void
+GNUNET_notification_context_add (struct GNUNET_NotificationContext *nc,
+                                struct GNUNET_MQ_Handle *mq);
+
+
+/**
+ * Send a message to all subscribers of this context.
+ *
+ * @param nc context to modify
+ * @param msg message to send
+ * @param can_drop can this message be dropped due to queue length limitations
+ */
+void
+GNUNET_notification_context_broadcast (struct GNUNET_NotificationContext *nc,
+                                      const struct GNUNET_MessageHeader *msg,
+                                      int can_drop);
+
+/**
+ * Return active number of subscribers in this context.
+ *
+ * @param nc context to query
+ * @return number of current subscribers
+ */
+unsigned int
+GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc);
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]