public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Lyude Paul" <lyude@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"John Stultz" <jstultz@google.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Daniel Almeida" <daniel.almeida@collabora.com>
Subject: Re: [PATCH v2] hrtimer: add usage examples to documentation
Date: Thu, 19 Feb 2026 14:35:39 +0100	[thread overview]
Message-ID: <87o6lkamac.fsf@kernel.org> (raw)
In-Reply-To: <aZcChDe_Y3eyLuYS@google.com>

"Alice Ryhl" <aliceryhl@google.com> writes:

> On Thu, Feb 19, 2026 at 12:57:45PM +0100, Andreas Hindborg wrote:
>> Add documentation examples showing various ways to use hrtimers:
>>
>> - Box-allocated timers with shared state in Arc.
>> - Arc-allocated timers.
>> - Stack-based timers for scoped usage.
>> - Mutable stack-based timers with shared state.
>>
>> Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
>> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
>> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
>
>> ---
>> Changes in v2:
>> - Sprinkle blank lines for readability
>> - Change heading for Arc example
>> - Fix error handling.
>> - Link to v1: https://lore.kernel.org/r/20251217-hrtimer-examples-v6-19-rc1-v1-1-4ad0e7e4c4e0@kernel.org
>> ---
>>  rust/kernel/time/hrtimer.rs | 336 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 336 insertions(+)
>>
>> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
>> index 856d2d929a008..2d7f1131a8131 100644
>> --- a/rust/kernel/time/hrtimer.rs
>> +++ b/rust/kernel/time/hrtimer.rs
>> @@ -66,6 +66,342 @@
>>  //!
>>  //! A `restart` operation on a timer in the **stopped** state is equivalent to a
>>  //! `start` operation.
>> +//!
>> +//! When a type implements both `HrTimerPointer` and `Clone`, it is possible to
>> +//! issue the `start` operation while the timer is in the **started** state. In
>> +//! this case the `start` operation is equivalent to the `restart` operation.
>> +//!
>> +//! # Examples
>> +//!
>> +//! ## Using an intrusive timer living in a [`Box`]
>> +//!
>> +//! ```
>> +//! # use kernel::{
>> +//! #     alloc::flags,
>> +//! #     impl_has_hr_timer,
>> +//! #     prelude::*,
>> +//! #     sync::{
>> +//! #         atomic::{ordering, Atomic},
>> +//! #         completion::Completion,
>> +//! #         Arc,
>> +//! #     },
>> +//! #     time::{
>> +//! #         hrtimer::{
>> +//! #             RelativeMode, HrTimer, HrTimerCallback, HrTimerPointer,
>> +//! #             HrTimerRestart, HrTimerCallbackContext
>> +//! #         },
>> +//! #         Delta, Monotonic,
>> +//! #     },
>> +//! # };
>> +//!
>
> Either do not hide the imports, or remove this empty newline.

This got me a few times already.

I'm undecided if it is better to hide the imports or not. What do people
think?


Best regards,
Andreas Hindborg


  reply	other threads:[~2026-02-19 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 11:57 [PATCH v2] hrtimer: add usage examples to documentation Andreas Hindborg
2026-02-19 12:31 ` Alice Ryhl
2026-02-19 13:35   ` Andreas Hindborg [this message]
2026-02-19 13:39     ` Alice Ryhl
2026-03-23 11:07 ` 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=87o6lkamac.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox