From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp37.i.mail.ru (smtp37.i.mail.ru [94.100.177.97]) (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 927D3469719 for ; Mon, 9 Nov 2020 15:49:46 +0300 (MSK) References: <8642a26fc2530318c1ef755d706d6bedc9d59684.1604858551.git.v.shpilevoy@tarantool.org> From: Serge Petrenko Message-ID: <3856eab8-f039-e3ac-c07d-891faf1b4570@tarantool.org> Date: Mon, 9 Nov 2020 15:49:45 +0300 MIME-Version: 1.0 In-Reply-To: <8642a26fc2530318c1ef755d706d6bedc9d59684.1604858551.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 1/4] fiber: introduce fiber.arg List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com 08.11.2020 21:03, Vladislav Shpilevoy пишет: > Struct fiber has a member va_list f_data. It is used to forward > arguments to the fiber function when fiber_start() is called, > right from the caller's stack. > > But it is useless when fiber is started asynchronously, with > fiber_new + fiber_wakeup. And there is no way to pass anything > into such a fiber. > > This patch adds a new member 'void *arg', which shares memory with > va_list f_data, and can be used to pass something into the fiber. > > The feature is going to be used by raft. Currently raft worker > fiber works only with global variables, but soon it will need to > have its own pointer at struct raft object. And it can't be > started with fiber_start(), because raft code does not yield > anywhere in its state machine. > > Needed for #5303 Hi! Thanks for the patch! LGTM. > --- > src/lib/core/fiber.h | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h > index 539e5c8e7..08f1dd662 100644 > --- a/src/lib/core/fiber.h > +++ b/src/lib/core/fiber.h > @@ -565,7 +565,19 @@ struct fiber { > * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31488 > */ > fiber_func f; > - va_list f_data; > + union { > + /** > + * Argument list passed when the fiber is invoked in a blocking > + * way, so the caller may pass arguments from its own stack. > + */ > + va_list f_data; > + /** > + * Fiber function argument which passed asynchronously. Can be > + * used not to call fiber_start to avoid yields, but still pass > + * something into the fiber. > + */ > + void *arg; > + }; > int f_ret; > /** Fiber local storage. */ > struct { -- Serge Petrenko