diff --git a/src/common/libutil/Makefile.am b/src/common/libutil/Makefile.am index 46e7927ffd01..ac4b23197379 100644 --- a/src/common/libutil/Makefile.am +++ b/src/common/libutil/Makefile.am @@ -35,8 +35,6 @@ libutil_la_SOURCES = \ read_all.h \ ev_zmq.c \ ev_zmq.h \ - ev_zlist.c \ - ev_zlist.h \ base64.c \ base64.h \ msglist.c \ diff --git a/src/common/libutil/ev_zlist.c b/src/common/libutil/ev_zlist.c deleted file mode 100644 index da132ac96819..000000000000 --- a/src/common/libutil/ev_zlist.c +++ /dev/null @@ -1,87 +0,0 @@ -/*****************************************************************************\ - * Copyright (c) 2015 Lawrence Livermore National Security, LLC. Produced at - * the Lawrence Livermore National Laboratory (cf, AUTHORS, DISCLAIMER.LLNS). - * LLNL-CODE-658032 All rights reserved. - * - * This file is part of the Flux resource manager framework. - * For details, see https://github.com/flux-framework. - * - * This program 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 2 of the license, or (at your option) - * any later version. - * - * Flux 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 terms and conditions of the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * See also: http://www.gnu.org/licenses/ -\*****************************************************************************/ - -#include - -#include "src/common/libev/ev.h" -#include "src/common/libutil/ev_zlist.h" - -static void prepare_cb (struct ev_loop *loop, ev_prepare *w, int revents) -{ - ev_zlist *zw = (ev_zlist *)((char *)w - offsetof (ev_zlist, prepare_w)); - - revents = 0; - if ((zw->events & EV_READ) && zlist_size (zw->zlist) > 0) - revents |= EV_READ; - if ((zw->events & EV_WRITE)) - revents |= EV_WRITE; - if (revents) - ev_idle_start (loop, &zw->idle_w); -} - -static void check_cb (struct ev_loop *loop, ev_check *w, int revents) -{ - ev_zlist *zw = (ev_zlist *)((char *)w - offsetof (ev_zlist, check_w)); - - ev_idle_stop (loop, &zw->idle_w); - - revents = 0; - if ((zw->events & EV_READ) && zlist_size (zw->zlist) > 0) - revents |= EV_READ; - if ((zw->events & EV_WRITE)) - revents |= EV_WRITE; - if (revents) - zw->cb (loop, zw, revents); -} - -int ev_zlist_init (ev_zlist *w, ev_zlist_cb cb, zlist_t *zlist, int events) -{ - w->cb = cb; - w->events = events; - w->zlist = zlist; - - ev_prepare_init (&w->prepare_w, prepare_cb); - ev_check_init (&w->check_w, check_cb); - ev_idle_init (&w->idle_w, NULL); - - return 0; -} - -void ev_zlist_start (struct ev_loop *loop, ev_zlist *w) -{ - ev_prepare_start (loop, &w->prepare_w); - ev_check_start (loop, &w->check_w); -} - -void ev_zlist_stop (struct ev_loop *loop, ev_zlist *w) -{ - ev_prepare_stop (loop, &w->prepare_w); - ev_check_stop (loop, &w->check_w); - ev_idle_stop (loop, &w->idle_w); -} - -/* - * vi:tabstop=4 shiftwidth=4 expandtab - */ - diff --git a/src/common/libutil/ev_zlist.h b/src/common/libutil/ev_zlist.h deleted file mode 100644 index a6d2418ade43..000000000000 --- a/src/common/libutil/ev_zlist.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _EV_ZLIST_H -#define _EV_ZLIST_H - -typedef struct ev_list_struct ev_zlist; -typedef void (*ev_zlist_cb)(struct ev_loop *loop, ev_zlist *w, int revents); - -struct ev_list_struct { - ev_prepare prepare_w; - ev_idle idle_w; - ev_check check_w; - zlist_t *zlist; - int events; - ev_zlist_cb cb; - void *data; -}; - -int ev_zlist_init (ev_zlist *w, ev_zlist_cb cb, zlist_t *zlist, int events); -void ev_zlist_start (struct ev_loop *loop, ev_zlist *w); -void ev_zlist_stop (struct ev_loop *loop, ev_zlist *w); - -#endif /* !_EV_ZLIST_H */ - -/* - * vi:tabstop=4 shiftwidth=4 expandtab - */ - diff --git a/src/common/libutil/test/ev.c b/src/common/libutil/test/ev.c index 57fef4ddf46c..53c730f655b1 100644 --- a/src/common/libutil/test/ev.c +++ b/src/common/libutil/test/ev.c @@ -4,7 +4,6 @@ #include "src/common/libutil/oom.h" #include "src/common/libev/ev.h" #include "src/common/libutil/ev_zmq.h" -#include "src/common/libutil/ev_zlist.h" #include "src/common/libtap/tap.h" void timer_arg_cb (struct ev_loop *loop, ev_timer *w, int revents) @@ -243,13 +242,6 @@ void test_ev_zmq (void) zmq_ctx_destroy (zctx); } -void list_cb (struct ev_loop *loop, ev_zlist *w, int revents) -{ - zmsg_t *zmsg = zlist_pop (w->zlist); - assert (zmsg != NULL); - zmsg_destroy (&zmsg); -} - void list_timer_cb (struct ev_loop *loop, ev_timer *w, int revents) { static int i = 100; @@ -263,47 +255,14 @@ void list_timer_cb (struct ev_loop *loop, ev_timer *w, int revents) } } -/* timer adds zmsgs to zlist, then stops reactor after 100. - */ -void test_ev_zlist (void) -{ - struct ev_loop *loop; - ev_zlist list_w; - ev_timer timer_w; - zlist_t *l; - zmsg_t *zmsg; - - ok ((loop = ev_loop_new (EVFLAG_AUTO)) != NULL, - "ev_loop_new works"); - - if (!(l = zlist_new ()) || !(zmsg = zmsg_new ()) - || zlist_append (l, zmsg) < 0) - oom (); - - ev_zlist_init (&list_w, list_cb, l, EV_READ); - ev_timer_init (&timer_w, list_timer_cb, 1E-3, 1E-3); - timer_w.data = l; - ev_zlist_start (loop, &list_w); - ev_timer_start (loop, &timer_w); - ok (ev_run (loop, 0) != 0 && zlist_size (l) == 0, - "ev_zlist handler ran 100 times"); - ev_zlist_stop (loop, &list_w); - ev_timer_stop (loop, &timer_w); - - if (l) - zlist_destroy (&l); - ev_loop_destroy (loop); -} - int main (int argc, char *argv[]) { - plan (29); + plan (27); test_libev_timer (); // 5 test_libev_io (); // 3 test_zmq_events (); // 13 test_ev_zmq (); // 6 - test_ev_zlist (); // 2 done_testing (); }