X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8cabab2212c60733053696558fe70447e8c421c9..7a9c17db0fc11a2255e080c5cc9bb0a0f5642c82:/src/xbt/dynar.c diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index b6af152c52..794af42d18 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -15,9 +15,6 @@ #include "xbt/dynar.h" #include -#include "xbt/dynar_private.h" /* type definition, which we share with the - code in charge of sending this across the net */ - /* IMPLEMENTATION NOTE ON SYNCHRONIZATION: every functions which name is prefixed by _ * assumes that the dynar is already locked if we have to. * Other functions (public ones) check for this. @@ -659,67 +656,14 @@ static void _dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op) void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op) { - _dynar_lock(dynar); _sanity_check_dynar(dynar); + _dynar_lock(dynar); _dynar_map(dynar, op); _dynar_unlock(dynar); } -/** @brief Put the cursor at the begining of the dynar. - * - * Actually, the cursor is set one step before the begining, so that you - * can iterate over the dynar with a for loop. - * - * @warning Do not call this function directly, but only through xbt_dynar_foreach. - */ -void -_xbt_dynar_cursor_first(const xbt_dynar_t dynar, unsigned int *const cursor) -{ - - _dynar_lock(dynar); - DEBUG1("Set cursor on %p to the first position", (void *) dynar); - *cursor = 0; -} - -/** @brief Move the cursor to the next value - * - * @warning Do not call this function directly, but only through xbt_dynar_foreach. - */ -void -_xbt_dynar_cursor_step(const xbt_dynar_t dynar, unsigned int *const cursor) -{ - - (*cursor)++; -} - -/** @brief Get the data currently pointed by the cursor - * - * @warning Do not call this function directly, but only through xbt_dynar_foreach. - */ -int -_xbt_dynar_cursor_get(const xbt_dynar_t dynar, - unsigned int *const cursor, void *const dst) -{ - - _sanity_check_dynar(dynar); - { - - const unsigned long idx = *cursor; - - if (idx >= dynar->used) { - DEBUG1("Cursor on %p already on last elem", (void *) dynar); - _dynar_unlock(dynar); - return FALSE; - } - DEBUG2("Cash out cursor on %p at %lu", (void *) dynar, idx); - - _xbt_dynar_get_elm(dst, dynar, idx); - } - return TRUE; - -} /** @brief Removes and free the entry pointed by the cursor * @@ -1204,8 +1148,8 @@ XBT_TEST_UNIT("synchronized int", test_dynar_sync_int,"Synchronized dynars of in xbt_test_add0("==== Have a pusher and a popper on the dynar"); d = xbt_dynar_new_sync(sizeof(int), NULL); - pusher = xbt_thread_create("pusher", pusher_f, d); - poper = xbt_thread_create("poper", poper_f, d); + pusher = xbt_thread_create("pusher", pusher_f, d,0/*not joinable*/); + poper = xbt_thread_create("poper", poper_f, d,0/*not joinable*/); xbt_thread_join(pusher); xbt_thread_join(poper); xbt_dynar_free(&d);