From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 8A8214696C3 for ; Mon, 13 Apr 2020 12:53:46 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) From: Serge Petrenko In-Reply-To: <20200411163358.GU3072@uranus> Date: Mon, 13 Apr 2020 12:53:45 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <7EA6DA75-7106-4E6B-9AC7-59B82B718717@tarantool.org> References: <20200411163358.GU3072@uranus> Subject: Re: [Tarantool-patches] [PATCH 1/2] trigger: add trigger_is_set() method List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org > 11 =D0=B0=D0=BF=D1=80. 2020 =D0=B3., =D0=B2 19:33, Cyrill Gorcunov = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > On Sat, Apr 11, 2020 at 03:33:44PM +0300, Serge Petrenko wrote: >> --- >> src/lib/core/trigger.h | 6 ++++++ >> 1 file changed, 6 insertions(+) >>=20 >> diff --git a/src/lib/core/trigger.h b/src/lib/core/trigger.h >> index 7b500dd92..ae477ad70 100644 >> --- a/src/lib/core/trigger.h >> +++ b/src/lib/core/trigger.h >> @@ -95,6 +95,12 @@ trigger_add_unique(struct rlist *list, struct = trigger *trigger) >> trigger_add(list, trigger); >> } >>=20 >> +static inline int >> +trigger_is_set(struct trigger *trigger) >> +{ >> + return !rlist_empty(&trigger->link); >> +} >> + >=20 > Wait. Serge, you know I don;t like it. Can't we rather provide > normal static initializer say like Hi! Thanks for the review! >=20 > --- > diff --git a/src/lib/core/trigger.h b/src/lib/core/trigger.h > index 7b500dd92..e9c6dd17e 100644 > --- a/src/lib/core/trigger.h > +++ b/src/lib/core/trigger.h > @@ -59,6 +59,14 @@ struct trigger > trigger_f0 destroy; > }; >=20 > +#define DECLARE_TRIGGER(__name, __run, __data, __destroy) \ > + struct trigger __name =3D { \ > + .link =3D RLIST_HEAD_INITIALIZER(__name.link), \ > + .run =3D __run, \ > + .data =3D __data, \ > + .destroy=3D __destroy, \ > + } > + >=20 > and simply declare the trigger >=20 > diff --git a/src/box/relay.cc b/src/box/relay.cc > index c634348a4..cdc20dc5b 100644 > --- a/src/box/relay.cc > +++ b/src/box/relay.cc > @@ -580,9 +580,7 @@ relay_subscribe_f(va_list ap) > * Not needed for anonymous replicas, since they > * aren't registered with gc at all. > */ > - struct trigger on_close_log =3D { > - RLIST_LINK_INITIALIZER, relay_on_close_log_f, relay, = NULL > - }; > + DECLARE_TRIGGER(on_close_log, relay_on_close_log_f, relay, = NULL); > if (!relay->replica->anon) > trigger_add(&r->on_close_log, &on_close_log); >=20 > so that trigger_clear won't fail without if statement? This is doing the same as trigger_create(&&on_close_log); Let=E2=80=99s just omit the if statement then together with the patch adding trigger_is_set()? -- Serge Petrenko sergepetrenko@tarantool.org