From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Tejun Heo" <tj@kernel.org>, "Miguel Ojeda" <ojeda@kernel.org>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Philipp Stanner" <phasta@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Boqun Feng" <boqun@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>
Subject: Re: [PATCH v4 3/3] rust: workqueue: add creation of workqueues
Date: Mon, 16 Mar 2026 11:43:41 +0100 [thread overview]
Message-ID: <DH4582TWS3WF.10WYLC267YNRR@kernel.org> (raw)
In-Reply-To: <abU4oXeCesOJr46H@google.com>
On Sat Mar 14, 2026 at 11:30 AM CET, Alice Ryhl wrote:
> On Thu, Mar 12, 2026 at 06:59:31PM +0100, Danilo Krummrich wrote:
>> On Thu Mar 12, 2026 at 10:23 AM CET, Alice Ryhl wrote:
>> > +impl Queue {
>> > + /// Build a workqueue whose work may execute on any cpu.
>> > + ///
>> > + /// # Examples
>> > + ///
>> > + /// ```
>> > + /// use kernel::workqueue::Queue;
>> > + ///
>> > + /// let wq = Queue::new_unbound().build(c"my-wq")?;
>> > + /// wq.try_spawn(GFP_KERNEL, || pr_info!("Hello from unbound wq"))?;
>> > + /// # Ok::<(), Error>(())
>> > + /// ```
>> > + #[inline]
>> > + #[doc(alias = "WQ_UNBOUND")]
>> > + pub fn new_unbound() -> Builder<TypeUnbound> {
>>
>> Wouldn't it be more straight forward if those where constructors of Builder?
>>
>> let wq = wq::Builder::new_unbound().build(c"my-wq")?;
>
> Crates out there do both, but I actually like this pattern quite a lot.
> After all, given 'wq::Builder::new_unbound()' and 'Queue::new_unbound()'
> I think the latter is the one that makes it more clear that you are
> building a 'Queue'.
>
> Also, it avoids an extra import.
If it is about avoiding an extra import, what about
Queue::builder_unbound()
this makes the name less misleading and avoids the import.
>> Queue::new_unbound() suggests that it returns a new Queue object, but instead it
>> returns a new Builder object.
>
> I'm only really concerned about confusion if it falls into one of these
> categories:
>
> * You write the wrong code, it compiles, and silently does the wrong
> thing.
> * You read the code, and misunderstand what it does.
>
> I don't think this falls into either of those cases. If you forget the
> .build() call, all you get is a compiler error, and it's not hard to
> figure out what to do when you see the error.
>
> Alice
next prev parent reply other threads:[~2026-03-16 11:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 9:23 [PATCH v4 0/3] Creation of workqueues in Rust Alice Ryhl
2026-03-12 9:23 ` [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs Alice Ryhl
2026-03-16 10:24 ` Andreas Hindborg
2026-03-12 9:23 ` [PATCH v4 2/3] rust: workqueue: create workqueue subdirectory Alice Ryhl
2026-03-12 9:23 ` [PATCH v4 3/3] rust: workqueue: add creation of workqueues Alice Ryhl
2026-03-12 16:39 ` Gary Guo
2026-03-12 22:56 ` Alice Ryhl
2026-03-13 13:25 ` Gary Guo
2026-03-13 13:29 ` Gary Guo
2026-03-14 10:31 ` Alice Ryhl
2026-03-12 17:59 ` Danilo Krummrich
2026-03-14 10:30 ` Alice Ryhl
2026-03-16 10:43 ` Danilo Krummrich [this message]
2026-03-16 10:24 ` Andreas Hindborg
2026-03-16 10:57 ` Andreas Hindborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DH4582TWS3WF.10WYLC267YNRR@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=phasta@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tj@kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.