Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] Re: [PATCH 1/1] box: expose on_commit/rollback triggers for Lua
Date: Fri, 17 Aug 2018 18:15:36 +0300	[thread overview]
Message-ID: <20180817151536.qbb4pwgdagnd367t@esperanza> (raw)
In-Reply-To: <fbbd9750-1653-4778-bdce-4f440699ac97@tarantool.org>

On Fri, Aug 17, 2018 at 05:45:24PM +0300, Vladislav Shpilevoy wrote:
> Hi! Thanks for the review.
> 
> On 17/08/2018 14:21, Vladimir Davydov wrote:
> > On Thu, Aug 16, 2018 at 08:57:10PM +0300, Vladislav Shpilevoy wrote:
> > > +/**
> > > + * Update the transaction on_commit/rollback triggers.
> > > + * @sa lbox_trigger_reset.
> > > + */
> > > +#define lbox_on_txn_end(name) do {                                             \
> > > +	struct txn *txn = in_txn();                                            \
> > > +	int top = lua_gettop(L);                                               \
> > > +	if (top > 2 || txn == NULL) {                                          \
> > > +		return luaL_error(L, "Usage inside a transaction: "            \
> > > +				  "box.on_" #name "([function | nil, "         \
> > > +				  "[function | nil]])");                       \
> > > +	}                                                                      \
> > > +	txn_init_triggers(txn);                                                \
> > > +	return lbox_trigger_reset(L, 2, &txn->on_##name, lbox_push_txn, NULL); \
> > > +} while (0)
> > > +
> > > +static int
> > > +lbox_on_commit(struct lua_State *L)
> > > +{
> > > +	lbox_on_txn_end(commit);
> > > +}
> > > +
> > > +static int
> > > +lbox_on_rollback(struct lua_State *L)
> > > +{
> > > +	lbox_on_txn_end(rollback);
> > > +}
> > > +
> > 
> > This is nit-picking, but IMHO better define the whole function
> > in a macro.
> > 
> > #define LBOX_TXN_TRIGGER(name)					\
> > static int							\
> > lbox_on_##name(struct lua_State *L)				\
> > ...
> > 
> > LBOX_TXN_TRIGGER(commit)
> > LBOX_TXN_TRIGGER(rollback)
> > 
> > Other than that the patch looks good to me.
> > 
> 
> Fixed.

ACK for

9a8da517177a1b2609615252b7cec4348145b543 box: expose on_commit/rollback triggers for Lua

  reply	other threads:[~2018-08-17 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 17:57 Vladislav Shpilevoy
2018-08-17  8:40 ` Vladimir Davydov
2018-08-17 14:45   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-17 11:21 ` Vladimir Davydov
2018-08-17 14:45   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-17 15:15     ` Vladimir Davydov [this message]
2018-08-17 15:42 ` [tarantool-patches] " Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180817151536.qbb4pwgdagnd367t@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] Re: [PATCH 1/1] box: expose on_commit/rollback triggers for Lua' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox