[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Faking EVLOOP_NO_EXIT_ON_EMPTY on earlier versions



Hi,

You could add a dummy timer (with a cb doing nothing) to the evloop,
and it won't exit as its not empty.

static void dummy(evutil_socket_t fd, short what, void *arg)
{
}

    struct event* ev = event_new(base_loop, -1, EV_PERSIST, dummy, NULL);
    struct timeval timeout_val;
    timeout_val.tv_sec = 40000; //or higher
    timeout_val.tv_usec = 0;
    evtimer_add(ev, &timeout_val);

br,

Jan

On Wed, Aug 17, 2016 at 5:32 PM, Philip Prindeville
<philipp_subx@xxxxxxxxxxxxxxxxxxxxx> wrote:
> I'm working on a program (a Tacacs+ proxy) which, for now, has 2 threads one
> which listens to DBus requests (not using libevent, but I'll change that
> eventually) and another which manages TCP sockets (via the bufferevent
> stuff) inside an event_base_dispatch().
>
> I'm on Debian 8 and have 2.0.5 installed... I don't have
> EVLOOP_NO_EXIT_ON_EMPTY available since that was introduced in 2.1.1.
>
> Is there an easy way to get the same functionality without burning a lot of
> CPU with:
>
>     while (1)
>         event_base_dispatch(evbase);
>
> Thanks,
>
> -Philip
>
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users    in the body.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.