Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[xbt] Kill the queue datacontainer: it made more sense with GRAS
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 21 Jan 2016 10:00:48 +0000 (11:00 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 21 Jan 2016 10:01:23 +0000 (11:01 +0100)
ChangeLog
include/xbt.h
include/xbt/queue.h [deleted file]
src/xbt/log.c
src/xbt/xbt_queue.c [deleted file]
tools/cmake/DefinePackages.cmake

index 6324290..903b09b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@ SimGrid (3.13) UNRELEASED; urgency=low
 
  XBT
  * Kill the setset datacontainer: it's unused since a while.
+ * Kill the queue datacontainer: it made more sense with GRAS.
  
  JAVA:
  * Remove the ability to write internal plugins in Java. 
index 5675b55..16de299 100644 (file)
@@ -26,7 +26,6 @@
 #include <xbt/set.h>
 #include <xbt/swag.h>
 #include <xbt/heap.h>
-#include <xbt/queue.h>
 #include <xbt/parmap.h>
 
 #include <xbt/peer.h>
diff --git a/include/xbt/queue.h b/include/xbt/queue.h
deleted file mode 100644 (file)
index ab918ff..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* A (synchronized) message queue.                                          */
-/* Popping an empty queue is blocking, as well as pushing a full one        */
-
-/* Copyright (c) 2007, 2009-2011, 2013-2014. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef _XBT_QUEUE_H
-#define _XBT_QUEUE_H
-
-#include "xbt/misc.h"           /* SG_BEGIN_DECL */
-/* #include "xbt/function_types.h" */
-
-SG_BEGIN_DECL()
-
-/** @addtogroup XBT_queue
-  * \brief Synchronized message exchanging queue.
-  *
-  * These is the classical producer/consumer synchronization scheme, 
-  * which all concurrent programmer recode one day or another.
-  *
-  * The synchronization of this implementation is done within the SimGrid 
-  * realm, switching between SimGrid processes.
-  *  
-  * For performance concerns, the content of queue must be homogeneous, 
-  * just like dynars (see the \ref XBT_dynar section). Actually, queues use a 
-  * dynar to store the data, and add the synchronization on top of it. 
-  * 
-  * @{
-  */
-  /** \brief Queue data type (opaque type) */
-typedef struct s_xbt_queue_ *xbt_queue_t;
-
-
-XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity,
-                                      unsigned long elm_size);
-XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
-
-XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
-
-XBT_PUBLIC(void) xbt_queue_push(xbt_queue_t queue, const void *src);
-XBT_PUBLIC(void) xbt_queue_pop(xbt_queue_t queue, void *const dst);
-XBT_PUBLIC(void) xbt_queue_unshift(xbt_queue_t queue, const void *src);
-XBT_PUBLIC(void) xbt_queue_shift(xbt_queue_t queue, void *const dst);
-
-XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
-                                      double delay);
-XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue,
-                                         const void *src, double delay);
-XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
-                                       double delay);
-XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
-                                     double delay);
-
-/** @} */
-
-SG_END_DECL()
-#endif                          /* _XBT_QUEUE_H */
index 1c7ed51..47ff21a 100644 (file)
@@ -584,7 +584,6 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(xbt_mallocator);
   XBT_LOG_CONNECT(xbt_matrix);
   XBT_LOG_CONNECT(xbt_parmap);
-  XBT_LOG_CONNECT(xbt_queue);
   XBT_LOG_CONNECT(xbt_set);
   XBT_LOG_CONNECT(xbt_sync);
   XBT_LOG_CONNECT(xbt_sync_os);
diff --git a/src/xbt/xbt_queue.c b/src/xbt/xbt_queue.c
deleted file mode 100644 (file)
index 68be624..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/* A (synchronized) message queue.                                          */
-/* Popping an empty queue is blocking, as well as pushing a full one        */
-
-/* Copyright (c) 2007-2014. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "xbt/misc.h"
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/dynar.h"
-#include "xbt/synchro_core.h"
-
-#include "xbt/queue.h"          /* this module */
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_queue, xbt,
-                                "Message exchanging queue");
-
-typedef struct s_xbt_queue_ {
-  int capacity;
-  xbt_dynar_t data;
-  xbt_mutex_t mutex;
-  xbt_cond_t not_full, not_empty;
-} s_xbt_queue_t;
-
-/** @brief Create a new message exchange queue.
- *
- * @param capacity the capacity of the queue. If non-nul, any attempt to push an item which would let the size of the queue over this number will be blocking until someone else pop some data
- * @param elm_size size of each element stored in it (see #xbt_dynar_new)
- */
-xbt_queue_t xbt_queue_new(int capacity, unsigned long elm_size)
-{
-  xbt_queue_t res = xbt_new0(s_xbt_queue_t, 1);
-  if (capacity<0)
-    capacity=0;
-
-  res->capacity = capacity;
-  res->data = xbt_dynar_new(elm_size, NULL);
-  res->mutex = xbt_mutex_init();
-  res->not_full = xbt_cond_init();
-  res->not_empty = xbt_cond_init();
-  return res;
-}
-
-/** @brief Destroy a message exchange queue.
- *
- * Any remaining content is leaked.
- */
-void xbt_queue_free(xbt_queue_t * queue)
-{
-
-  xbt_dynar_free(&((*queue)->data));
-  xbt_mutex_destroy((*queue)->mutex);
-  xbt_cond_destroy((*queue)->not_full);
-  xbt_cond_destroy((*queue)->not_empty);
-  free(*queue);
-  *queue = NULL;
-}
-
-/** @brief Get the queue size */
-unsigned long xbt_queue_length(const xbt_queue_t queue)
-{
-  unsigned long res;
-  xbt_mutex_acquire(queue->mutex);
-  res = xbt_dynar_length(queue->data);
-  xbt_mutex_release(queue->mutex);
-  return res;
-}
-
-/** @brief Push something to the message exchange queue.
- *
- * This is blocking if the declared capacity is non-nul, and if this amount is reached.
- *
- * @see #xbt_dynar_push
- */
-void xbt_queue_push(xbt_queue_t queue, const void *src)
-{
-  xbt_mutex_acquire(queue->mutex);
-  while (queue->capacity != 0
-         && queue->capacity == xbt_dynar_length(queue->data)) {
-    XBT_DEBUG("Capacity of %p exceeded (=%d). Waiting", queue,
-           queue->capacity);
-    xbt_cond_wait(queue->not_full, queue->mutex);
-  }
-  xbt_dynar_push(queue->data, src);
-  xbt_cond_signal(queue->not_empty);
-  xbt_mutex_release(queue->mutex);
-}
-
-
-/** @brief Pop something from the message exchange queue.
- *
- * This is blocking if the queue is empty.
- *
- * @see #xbt_dynar_pop
- *
- */
-void xbt_queue_pop(xbt_queue_t queue, void *const dst)
-{
-  xbt_mutex_acquire(queue->mutex);
-  while (xbt_dynar_is_empty(queue->data)) {
-    XBT_DEBUG("Queue %p empty. Waiting", queue);
-    xbt_cond_wait(queue->not_empty, queue->mutex);
-  }
-  xbt_dynar_pop(queue->data, dst);
-  xbt_cond_signal(queue->not_full);
-  xbt_mutex_release(queue->mutex);
-}
-
-/** @brief Unshift something to the message exchange queue.
- *
- * This is blocking if the declared capacity is non-nul, and if this amount is reached.
- *
- * @see #xbt_dynar_unshift
- */
-void xbt_queue_unshift(xbt_queue_t queue, const void *src)
-{
-  xbt_mutex_acquire(queue->mutex);
-  while (queue->capacity != 0
-         && queue->capacity == xbt_dynar_length(queue->data)) {
-    XBT_DEBUG("Capacity of %p exceeded (=%d). Waiting", queue,
-           queue->capacity);
-    xbt_cond_wait(queue->not_full, queue->mutex);
-  }
-  xbt_dynar_unshift(queue->data, src);
-  xbt_cond_signal(queue->not_empty);
-  xbt_mutex_release(queue->mutex);
-}
-
-
-/** @brief Shift something from the message exchange queue.
- *
- * This is blocking if the queue is empty.
- *
- * @see #xbt_dynar_shift
- *
- */
-void xbt_queue_shift(xbt_queue_t queue, void *const dst)
-{
-  xbt_mutex_acquire(queue->mutex);
-  while (xbt_dynar_is_empty(queue->data)) {
-    XBT_DEBUG("Queue %p empty. Waiting", queue);
-    xbt_cond_wait(queue->not_empty, queue->mutex);
-  }
-  xbt_dynar_shift(queue->data, dst);
-  xbt_cond_signal(queue->not_full);
-  xbt_mutex_release(queue->mutex);
-}
-
-
-
-
-/** @brief Push something to the message exchange queue, with a timeout.
- *
- * @see #xbt_queue_push
- */
-void xbt_queue_push_timed(xbt_queue_t queue, const void *src, double delay)
-{
-  double begin = xbt_time();
-
-  xbt_mutex_acquire(queue->mutex);
-
-  if (delay == 0) {
-    if (queue->capacity != 0 &&
-        queue->capacity == xbt_dynar_length(queue->data)) {
-
-      xbt_mutex_release(queue->mutex);
-      THROWF(timeout_error, 0,
-             "Capacity of %p exceeded (=%d), and delay = 0", queue,
-             queue->capacity);
-    }
-  } else {
-    while (queue->capacity != 0 &&
-           queue->capacity == xbt_dynar_length(queue->data) &&
-           (delay < 0 || (xbt_time() - begin) <= delay)) {
-
-      XBT_DEBUG("Capacity of %p exceeded (=%d). Waiting", queue,
-             queue->capacity);
-      TRY {
-        xbt_cond_timedwait(queue->not_full, queue->mutex,
-                           delay < 0 ? -1 : delay - (xbt_time() - begin));
-      }
-      CATCH_ANONYMOUS {
-        xbt_mutex_release(queue->mutex);
-        RETHROW;
-      }
-    }
-  }
-
-  xbt_dynar_push(queue->data, src);
-  xbt_cond_signal(queue->not_empty);
-  xbt_mutex_release(queue->mutex);
-}
-
-
-/** @brief Pop something from the message exchange queue, with a timeout.
- *
- * @see #xbt_queue_pop
- *
- */
-void xbt_queue_pop_timed(xbt_queue_t queue, void *const dst, double delay)
-{
-  double begin = xbt_time();
-
-  xbt_mutex_acquire(queue->mutex);
-
-  if (delay == 0) {
-    if (xbt_dynar_is_empty(queue->data)) {
-      xbt_mutex_release(queue->mutex);
-      THROWF(timeout_error, 0, "Delay = 0, and queue is empty");
-    }
-  } else {
-    while ((xbt_dynar_is_empty(queue->data)) &&
-           (delay < 0 || (xbt_time() - begin) <= delay)) {
-      XBT_DEBUG("Queue %p empty. Waiting", queue);
-      TRY {
-        xbt_cond_timedwait(queue->not_empty, queue->mutex,
-                           delay < 0 ? -1 : delay - (xbt_time() - begin));
-      }
-      CATCH_ANONYMOUS {
-        xbt_mutex_release(queue->mutex);
-        RETHROW;
-      }
-    }
-  }
-
-  xbt_dynar_pop(queue->data, dst);
-  xbt_cond_signal(queue->not_full);
-  xbt_mutex_release(queue->mutex);
-}
-
-/** @brief Unshift something to the message exchange queue, with a timeout.
- *
- * @see #xbt_queue_unshift
- */
-void xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,
-                             double delay)
-{
-  double begin = xbt_time();
-
-  xbt_mutex_acquire(queue->mutex);
-
-  if (delay == 0) {
-    if (queue->capacity != 0 &&
-        queue->capacity == xbt_dynar_length(queue->data)) {
-
-      xbt_mutex_release(queue->mutex);
-      THROWF(timeout_error, 0,
-             "Capacity of %p exceeded (=%d), and delay = 0", queue,
-             queue->capacity);
-    }
-  } else {
-    while (queue->capacity != 0 &&
-           queue->capacity == xbt_dynar_length(queue->data) &&
-           (delay < 0 || (xbt_time() - begin) <= delay)) {
-
-      XBT_DEBUG("Capacity of %p exceeded (=%d). Waiting", queue,
-             queue->capacity);
-      TRY {
-        xbt_cond_timedwait(queue->not_full, queue->mutex,
-                           delay < 0 ? -1 : delay - (xbt_time() - begin));
-      }
-      CATCH_ANONYMOUS {
-        xbt_mutex_release(queue->mutex);
-        RETHROW;
-      }
-    }
-  }
-
-  xbt_dynar_unshift(queue->data, src);
-  xbt_cond_signal(queue->not_empty);
-  xbt_mutex_release(queue->mutex);
-}
-
-
-/** @brief Shift something from the message exchange queue, with a timeout.
- *
- * @see #xbt_queue_shift
- *
- */
-void xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
-                           double delay)
-{
-  double begin = xbt_time();
-
-  xbt_mutex_acquire(queue->mutex);
-
-  if (delay == 0) {
-    if (xbt_dynar_is_empty(queue->data)) {
-      xbt_mutex_release(queue->mutex);
-      THROWF(timeout_error, 0, "Delay = 0, and queue is empty");
-    }
-  } else {
-    while ((xbt_dynar_is_empty(queue->data)) &&
-           (delay < 0 || (xbt_time() - begin) <= delay)) {
-      XBT_DEBUG("Queue %p empty. Waiting", queue);
-      TRY {
-        xbt_cond_timedwait(queue->not_empty, queue->mutex,
-                           delay < 0 ? -1 : delay - (xbt_time() - begin));
-      }
-      CATCH_ANONYMOUS {
-        xbt_mutex_release(queue->mutex);
-        RETHROW;
-      }
-    }
-  }
-
-  if (xbt_dynar_is_empty(queue->data)) {
-    xbt_mutex_release(queue->mutex);
-    THROWF(timeout_error, 0, "Timeout (%f) elapsed, but queue still empty",
-           delay);
-  }
-
-  xbt_dynar_shift(queue->data, dst);
-  xbt_cond_signal(queue->not_full);
-  xbt_mutex_release(queue->mutex);
-}
index af8542c..1ee036b 100644 (file)
@@ -284,7 +284,6 @@ set(XBT_SRC
   src/xbt/xbt_os_time.c
   src/xbt/xbt_os_file.c
   src/xbt/xbt_peer.c
-  src/xbt/xbt_queue.c
   src/xbt/xbt_replay.c
   src/xbt/xbt_sg_synchro.c
   src/xbt/xbt_sha.c
@@ -718,7 +717,6 @@ set(headers_to_install
   include/xbt/module.h
   include/xbt/parmap.h
   include/xbt/peer.h
-  include/xbt/queue.h
   include/xbt/replay.h
   include/xbt/set.h
   include/xbt/str.h