From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1419CC7EE24 for ; Wed, 31 May 2023 09:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234992AbjEaJIU (ORCPT ); Wed, 31 May 2023 05:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235372AbjEaJIJ (ORCPT ); Wed, 31 May 2023 05:08:09 -0400 Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25C28E4C for ; Wed, 31 May 2023 02:08:02 -0700 (PDT) Received: by mail-ed1-x549.google.com with SMTP id 4fb4d7f45d1cf-514b05895f7so1409521a12.0 for ; Wed, 31 May 2023 02:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685524080; x=1688116080; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h4XB69pI7oS1KTwJ1Q82+CkziVn4Zul+krCxNc20lxY=; b=hF5rhGXPOOd8eZdQQ3DNkBzapxJtKf68EiAo1a9IPWpXaz7OSTkyCGpwOoBmhtq444 Edz0OVUOK2gCHE/qi5uSIDR+CfACSpofs3x7IPacH+5ka1Re4i5bYKMFCatM9wFkNQCR Kynv+nF73kgFpbzeZIT0fCY5WE7tXNEeMjTCQ2/oMNfLncKxNwr3tD+Rozz0gncc5H81 L5MJaSrp0rJcoKjbIO4eQ5ZASfjN/sj5umJekwonfsGtrcZ+B7OpWx53w20tpFUp2C9L aWsG1eCu1roXKzUnkjDzPDLMcmI4nnBA7iBxTXLQ/oHhQvaExejAwggwLNG5S0tLKbJT o0xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685524080; x=1688116080; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h4XB69pI7oS1KTwJ1Q82+CkziVn4Zul+krCxNc20lxY=; b=DbDeQCuC7I0rLLCwdwiW0t31O997nswLrhSAguNcLepipiuAHHcJzQDTfFGEPo3zsf P6a229WWpNiyz7l8uvdSPCS9Q3C93X7uX6QYR9p/aFHFlUq+Al9gBHAQG5xTk3o1nUs4 MkNI5KMptazaqBe+bnF18uGEGZ5r/ChNxC9EOnxBcl2Aa6LOSvXiiOLuRQsfTW2DgDcJ /WlPtOzjjLKuu+LSDQYKQSs6eT0NI6tT988uuK7rJQGADByJUiAyUO2eqG8DqcWsl2dg zStJLRO6752YyLTYbXvOjVt4dQJYTldSYanRXF/CTYnXR0iCPMoTiFWOULhRRv8dgpnu gXxg== X-Gm-Message-State: AC+VfDyzT/9itfc13scoQ5+KehdYE4QRZxzNPFfNIU+GCOzqxsXMae23 FUnAioqHpgxauruixqfARDHquE2tEX5ue74= X-Google-Smtp-Source: ACHHUZ4jHWsOMdaL8fTbPxhKkMfcS5HXhNuYYha/28gUrN+9T6dw86HDPz24GnWXSS15B+jt4XcRCMsHnSQQxsk= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:6c8]) (user=aliceryhl job=sendgmr) by 2002:a17:907:75c6:b0:96f:4226:56d with SMTP id jl6-20020a17090775c600b0096f4226056dmr1253514ejc.6.1685524080625; Wed, 31 May 2023 02:08:00 -0700 (PDT) Date: Wed, 31 May 2023 09:07:58 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230531090758.3668499-1-aliceryhl@google.com> Subject: Re: [PATCH v1 6/7] rust: workqueue: add safe API to workqueue From: Alice Ryhl To: benno.lossin@proton.me Cc: alex.gaynor@gmail.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net, jiangshanlai@gmail.com, linux-kernel@vger.kernel.org, ojeda@kernel.org, patches@lists.linux.dev, rust-for-linux@vger.kernel.org, tj@kernel.org, wedsonaf@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Benno Lossin writes: > On Wednesday, May 17th, 2023 at 22:31, Alice Ryhl wrote: >> +macro_rules! define_work_adapter_newtype { >> + ( >> + $(#[$outer:meta])* >> + $pub:vis struct $name:ident( >> + $(#[$innermeta:meta])* >> + $fpub:vis Arc<$inner:ty> $(,)? >> + ); >> + $($rest:tt)* >> + ) => { >> + $(#[$outer])* >> + $pub struct $name($(#[$innermeta])* $fpub $crate::sync::Arc<$inner>); > > I am a bit confused as to why these types *contain* a pointer. Shouldn't > these be exactly the same `Work<$inner>`, except they allow multiple `run` > functions? So IMO they should embed a `Work<$inner>` and the > manually defined `run` function would take a `$inner`. No, that's not how this particular patch was designed. With the design I used, the way you tell `enqueue` which `work_struct` field you want to use is by using a different pointer type for each `work_struct` field. This macro defines those pointer types. So, for example, if you have only one `work_struct` field, then you just use `Arc` as your pointer type, and the field has type `Work>`. On the other hand, if you have two `work_struct` fields, then you instead use the macro to define `MyPointerType1` and `MyPoinerType2` that both wrap an `Arc`, and the fields then have types `Work` and `Work`. Alice