Skip to content

[feature] crossbeam-epoch pointers impl debug #463

Open
@DevinR528

Description

@DevinR528

For Atomic, Owned and Shared would there be interest in a more complete Debug implementation? I had a few ideas for going about this without getting in the way

  • #[cfg(feature = "debug"] would enable a whole different impl<T: Debug> Debug for _
  • a method Atomic::debug(&self) -> &dyn Debug
  • using autoref-specialization this would be the main impl<T: Debug> Debug for Owned and impl<T> Debug for &Owned would be the autoref fall back.

either way the general idea would be

let g = epoch::pin();
let data = self.data.load(Ordering::???);
let (raw, tag) = decompose_data::<T>(data);
let shared = self.load(Ordering::SeqCst, &g);
// this would be how all are "safely" printed unless I'm missing something
let inner = if shared.is_null() {
    &"null" as &dyn fmt::Debug
} else {
    unsafe { shared.deref() as &dyn fmt::Debug }
};
// if Debug
f.debug_struct("Atomic")
    .field("raw", &raw)
    .field("inner", inner)
    .field("tag", &tag)
    .finish()

If interested I can start a PR!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions