From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 354B7445320 for ; Thu, 23 Jul 2020 15:30:31 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id j11so6125436ljo.7 for ; Thu, 23 Jul 2020 05:30:31 -0700 (PDT) From: Cyrill Gorcunov Date: Thu, 23 Jul 2020 15:29:38 +0300 Message-Id: <20200723122942.196011-4-gorcunov@gmail.com> In-Reply-To: <20200723122942.196011-1-gorcunov@gmail.com> References: <20200723122942.196011-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 3/7] journal: add journal_entry_create helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy To create raw journal entries. We will use it to write confirm/rollback entries. Signed-off-by: Cyrill Gorcunov --- src/box/journal.c | 8 ++------ src/box/journal.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/box/journal.c b/src/box/journal.c index fb81acb39..159e32ff3 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -51,11 +51,7 @@ journal_entry_new(size_t n_rows, struct region *region, return NULL; } - entry->write_async_cb = write_async_cb; - entry->complete_data = complete_data; - entry->approx_len = 0; - entry->n_rows = n_rows; - entry->res = -1; - + journal_entry_create(entry, n_rows, 0, write_async_cb, + complete_data); return entry; } diff --git a/src/box/journal.h b/src/box/journal.h index 74a5eb050..fc33fd6f0 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -80,6 +80,27 @@ struct journal_entry { struct region; +/** + * Initialize a new journal entry. + */ +static inline void +journal_entry_create(struct journal_entry *entry, size_t n_rows, + size_t approx_len, + void (*write_async_cb)(struct journal_entry *entry), + void *complete_data) +{ + /* + * fifo member is left untouched because + * it is used by the journal engine internally, + * no need to waste time here. + */ + entry->write_async_cb = write_async_cb; + entry->complete_data = complete_data; + entry->approx_len = approx_len; + entry->n_rows = n_rows; + entry->res = -1; +} + /** * Create a new journal entry. * -- 2.26.2