[PATCH v2 1/2] Add function to wait for box.info.ro change

Vladimir Davydov vdavydov.dev at gmail.com
Fri Feb 2 11:44:11 MSK 2018


On Thu, Feb 01, 2018 at 08:35:05PM +0300, Vladimir Davydov wrote:
> This patch adds a new Lua function 'box.info.ro.wait(ro, timeout)'.
> The new function blocks the caller until 'box.info.ro' equals 'ro'
> or timeout passes or the fiber is cancelled.
> 
> Needed for #2537
> ---

> +static int
>  lbox_info_ro(struct lua_State *L)
>  {
>  	lua_pushboolean(L, box_is_ro());
> +	lua_newtable(L);
> +	lua_pushcfunction(L, lbox_info_ro_index);
> +	lua_setfield(L, -2, "__index");
> +	lua_setmetatable(L, -2);
>  	return 1;
>  }

This will change the metatable of all booleans, not just the one
returned by box.info.ro so we can't do that. We could make box.info.ro a
table with its own metatable which would have some methods overwritten
to make it mimic a boolean (__serialize, __eq), but that would be too
cumbersome, especially in case of more complex types, such as 'number'
(think of box.info.lsn and __le, __lt).



More information about the Tarantool-patches mailing list