Skip to content

Commit

Permalink
add const constructor for TypeIdSet
Browse files Browse the repository at this point in the history
  • Loading branch information
geeklint committed Apr 18, 2023
1 parent 4f787cb commit 2c709b5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ use std::thread;
/// A set of `TypeId`s held in a linked list.
#[derive(Default)]
pub struct TypeIdSet {
/// This pointer is either null (if the set has never been inserted to) or a
/// pointer to the first Node in the set.
head: atomic::AtomicPtr<Node>,
}

Expand Down Expand Up @@ -96,6 +98,15 @@ struct WaitingThreadNode {
}

impl TypeIdSet {
/// Create a new, empty, `TypeIdSet`.
#[cfg(not(loom))]
#[must_use]
pub const fn new() -> Self {
Self {
head: atomic::AtomicPtr::new(ptr::null_mut()),
}
}

/// Search linearly through the list for a node with the given `TypeId`. If it
/// was not found, return the value of the head pointer when we started
/// searching (it is assured a node with that `TypeId` cannot be found by
Expand Down

0 comments on commit 2c709b5

Please sign in to comment.