jonhoo / haphazard

Hazard pointers in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: retire without reclaim

elahn opened this issue · comments

Threads with tight latency or timing requirements (e.g. soft real-time, audio, high fps GUI) can't afford to reclaim when retiring objects.

There are two ways this could be exposed on HazPtrObject:

  1. unsafe fn retire_no_reclaim(this: *mut Self, deleter: &'static dyn Deleter) -> usize
  2. unsafe fn retire(this: *mut Self, allow_reclaim: bool, deleter: &'static dyn Deleter) -> usize

I mildly prefer (2). I'm happy to send a PR or leave for discussion on the next stream.

That's a good idea — please do send a PR! I prefer a separate method so that we can more easily document (by name and docs) that this will accumulate garbage over time, and what users should do when they do want to reclaim.

Some other ideas for names

  • retire_lazy
  • retire_later
  • mark_retired
  • retire_only