From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D7DAF45C304 for ; Tue, 15 Dec 2020 12:43:21 +0300 (MSK) References: <8b3f7ff8778f2270ce5598984b7df3750cdda4a6.1607879643.git.v.shpilevoy@tarantool.org> From: Serge Petrenko Message-ID: Date: Tue, 15 Dec 2020 12:43:18 +0300 MIME-Version: 1.0 In-Reply-To: <8b3f7ff8778f2270ce5598984b7df3750cdda4a6.1607879643.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH 2/8] fakesys: introduce fakeev_timer_remaining() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org 13.12.2020 20:15, Vladislav Shpilevoy пишет: > ev_timer_remaining() in libev returns number of seconds until the > timer will expire. It is used in raft code. > > Raft is going to be tested using fakesys, and it means it needs > fakeev analogue of ev_timer_remaining(). > > Part of #5303 Thanks for the patch! LGTM. > --- > src/lib/fakesys/fakeev.c | 10 ++++++++++ > src/lib/fakesys/fakeev.h | 4 ++++ > 2 files changed, 14 insertions(+) > > diff --git a/src/lib/fakesys/fakeev.c b/src/lib/fakesys/fakeev.c > index 8273c7ca8..715bf7b75 100644 > --- a/src/lib/fakesys/fakeev.c > +++ b/src/lib/fakesys/fakeev.c > @@ -282,6 +282,16 @@ fakeev_timer_start(struct ev_loop *loop, struct ev_timer *base) > fakeev_timer_event_new((struct ev_watcher *)base, base->at); > } > > +double > +fakeev_timer_remaining(struct ev_loop *loop, struct ev_timer *base) > +{ > + (void)loop; > + struct fakeev_event *e = fakeev_event_by_ev((struct ev_watcher *)base); > + if (e == NULL) > + return base->at; > + return e->deadline - fakeev_time(); > +} > + > void > fakeev_timer_again(struct ev_loop *loop, struct ev_timer *base) > { > diff --git a/src/lib/fakesys/fakeev.h b/src/lib/fakesys/fakeev.h > index 89954b2e1..6d1c4dcd1 100644 > --- a/src/lib/fakesys/fakeev.h > +++ b/src/lib/fakesys/fakeev.h > @@ -99,6 +99,10 @@ fakeev_loop(void); > void > fakeev_timer_start(struct ev_loop *loop, struct ev_timer *base); > > +/** Emulator of raft_ev_timer_remaining(). */ > +double > +fakeev_timer_remaining(struct ev_loop *loop, struct ev_timer *base); > + > /** Emulator of ev_timer_again(). */ > void > fakeev_timer_again(struct ev_loop *loop, struct ev_timer *base); -- Serge Petrenko