Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp591423rwd; Wed, 31 May 2023 02:39:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wXvtnCjopxP9z+X5vlcUH8qzKs2oraSxLbNT3X0moKJyuB+uVJCzcZoQq5dvq5WbK5TBT X-Received: by 2002:a05:6358:2904:b0:127:bde8:eeb0 with SMTP id y4-20020a056358290400b00127bde8eeb0mr1887601rwb.27.1685525943553; Wed, 31 May 2023 02:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685525943; cv=none; d=google.com; s=arc-20160816; b=NYY+LYniT/jn20ZIKQWxKWT0U2G5eClDQKsQhOXml1QLTc3vCMu0U/FLeiR7hDqKl1 sIfLzuCIWstEQZC4yS9djvYsECl1Se4EypHj8/jKHi1KHM5OSl4WCcsy3Hkvimra0XAM lMpPJCjTcqxDwnGR5sAEcbTjBEirdkOCK9Cg8COWSAcHNGNuS/IZMQopWZk/VpjN8tW6 rFCqvMlEcB7KULxWFkv4TpDVtC5fBhMUldrFsaqeLjfPu8yikuoRKvOAvCJbSLObfLak wHnwu8vJcNGwgvXElTOyt7I1vD8sxaTgKqZhPuvH+OW2QQmZwko53VlmFpYgR+xUx/px By4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=h4XB69pI7oS1KTwJ1Q82+CkziVn4Zul+krCxNc20lxY=; b=gmXsFZYTbvdR0+T4IpJumAv9iud8qnyZpp3lbJYlOnPmlDhrh8jLOH5k0Nf0Cx1cvO eAdDeOpjbJDj1reiH0f2mzhjfy99OKUF90i8hfRRQlfusp5mzUr8CxTmfta4d7JdBnov ULKBYnnBTSkEBMUEiqTpAGJqBDe1J4Pmgd8bDQRyDZegASgK5/9vxV56MB2RsTCc58A4 w2DbWgwi63rW5eW4nQZoHA4F0jYT1Jul9h2cafbr1xhu6FoMCUuw6r1hGtJ6Ex64xZMc BIXVr1n9c9wvZ1kwyDx4IXfKzs4vvOJDVaL+4ChKARZYmJTTT0NGTCyOOK40/uc0IgX6 wSvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hF5rhGXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a63be07000000b0053fb50702e9si660926pgf.407.2023.05.31.02.38.49; Wed, 31 May 2023 02:39:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hF5rhGXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234589AbjEaJIT (ORCPT + 99 others); Wed, 31 May 2023 05:08:19 -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-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" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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