feat: add instance_id actor primative

This commit is contained in:
CJ van den Berg 2026-03-10 12:55:54 +01:00
parent 685710c45b
commit fff2c268c2
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 27 additions and 0 deletions

View file

@ -66,4 +66,13 @@ auto thespian_handle_is_expired(thespian_handle h) -> bool {
h)};
return h_->expired();
}
auto thespian_handle_id(thespian_handle h) -> uintptr_t {
thespian::handle *h_{
reinterpret_cast<thespian::handle *>( // NOLINT(*-reinterpret-cast)
h)};
if (!h_)
return 0;
return thespian::instance_id(*h_);
}
}

View file

@ -125,6 +125,12 @@ fn Pid(comptime own: Ownership) type {
return c.thespian_handle_is_expired(self.h);
}
/// Stable opaque actor identity. Two handles for the same actor
/// return the same value. Returns 0 for a null/expired handle.
pub fn instance_id(self: Self) usize {
return c.thespian_handle_id(self.h);
}
pub fn wait_expired(self: Self, timeout_ns: isize) error{Timeout}!void {
var max_sleep: isize = timeout_ns;
while (!self.expired()) {