feat: add instance_id actor primative
This commit is contained in:
parent
685710c45b
commit
fff2c268c2
4 changed files with 27 additions and 0 deletions
|
|
@ -18,6 +18,9 @@ typedef struct thespian_handle_t *thespian_handle;
|
|||
|
||||
thespian_handle thespian_handle_clone(thespian_handle);
|
||||
void thespian_handle_destroy(thespian_handle);
|
||||
/* Stable opaque actor identity (raw instance pointer). Two handles for the
|
||||
same actor return the same value. Returns 0 for a null/expired handle. */
|
||||
uintptr_t thespian_handle_id(thespian_handle);
|
||||
|
||||
thespian_result thespian_handle_send_raw(thespian_handle, cbor_buffer);
|
||||
thespian_result thespian_handle_send_exit(thespian_handle, c_string_view);
|
||||
|
|
|
|||
|
|
@ -46,4 +46,13 @@ private:
|
|||
|
||||
auto operator==(const handle &, const handle &) -> bool;
|
||||
|
||||
/// Stable opaque actor identity: the raw instance pointer. Two handles for
|
||||
/// the same actor return the same value. Returns 0 for expired handles.
|
||||
[[nodiscard]] inline auto instance_id(const handle &h) -> uintptr_t {
|
||||
// NOLINTNEXTLINE(*-reinterpret-cast)
|
||||
if (auto sp = handle_ref(h).lock())
|
||||
return reinterpret_cast<uintptr_t>(sp.get());
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace thespian
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue