Skip to content

Commit

Permalink
rename liveliness token types
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Nov 19, 2024
1 parent 37e2a38 commit 50e5618
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions build-resources/opaque-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ get_opaque_type_data!(Subscriber<()>, z_loaned_subscriber_t);
/// expressions.
///
/// A DELETE on the token's key expression will be received by subscribers if the token is destroyed, or if connectivity between the subscriber and the token's creator is lost.
get_opaque_type_data!(Option<LivelinessToken>, zc_owned_liveliness_token_t);
get_opaque_type_data!(Option<LivelinessToken>, z_owned_liveliness_token_t);
#[cfg(feature = "unstable")]
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
get_opaque_type_data!(LivelinessToken, zc_loaned_liveliness_token_t);
get_opaque_type_data!(LivelinessToken, z_loaned_liveliness_token_t);
#[cfg(feature = "unstable")]
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief An owned Zenoh publication cache.
Expand Down
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ Liveliness
Types
-----

.. doxygenstruct:: zc_owned_liveliness_token_t
.. doxygenstruct:: z_owned_liveliness_token_t
.. doxygenstruct:: z_liveliness_token_options_t
.. doxygenstruct:: z_liveliness_get_options_t
.. doxygenstruct:: z_liveliness_subscriber_options_t
Expand Down
2 changes: 1 addition & 1 deletion examples/z_liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char** argv) {
}

printf("Declaring liveliness token '%s'...\n", args.keyexpr);
zc_owned_liveliness_token_t token;
z_owned_liveliness_token_t token;
if (z_liveliness_declare_token(z_loan(s), &token, z_loan(keyexpr), NULL) < 0) {
printf("Unable to create liveliness token!\n");
exit(-1);
Expand Down
40 changes: 20 additions & 20 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,22 @@ ZENOHC_API bool z_internal_keyexpr_check(const struct z_owned_keyexpr_t *this_);
* Constructs an owned key expression in a gravestone state.
*/
ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_);
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
bool z_internal_liveliness_token_check(const z_owned_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Constructs liveliness token in its gravestone state.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
void z_internal_liveliness_token_null(z_owned_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns ``true`` if `this` is valid.
Expand Down Expand Up @@ -3178,7 +3194,7 @@ z_result_t z_liveliness_declare_subscriber(const struct z_loaned_session_t *sess
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
z_result_t z_liveliness_declare_token(const struct z_loaned_session_t *session,
zc_owned_liveliness_token_t *token,
z_owned_liveliness_token_t *token,
const struct z_loaned_keyexpr_t *key_expr,
const struct z_liveliness_token_options_t *_options);
#endif
Expand Down Expand Up @@ -3220,15 +3236,15 @@ void z_liveliness_subscriber_options_default(struct z_liveliness_subscriber_opti
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
void z_liveliness_token_drop(zc_moved_liveliness_token_t *this_);
void z_liveliness_token_drop(z_moved_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Borrows token.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
const zc_loaned_liveliness_token_t *z_liveliness_token_loan(const zc_owned_liveliness_token_t *this_);
const z_loaned_liveliness_token_t *z_liveliness_token_loan(const z_owned_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Expand All @@ -3244,7 +3260,7 @@ void z_liveliness_token_options_default(struct z_liveliness_token_options_t *thi
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
z_result_t z_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_);
z_result_t z_liveliness_undeclare_token(z_moved_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Expand Down Expand Up @@ -4946,22 +4962,6 @@ bool zc_internal_closure_matching_status_check(const struct zc_owned_closure_mat
ZENOHC_API
void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_status_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Constructs liveliness token in its gravestone state.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Checks the matching listener is for the gravestone state
Expand Down
4 changes: 2 additions & 2 deletions splitguide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ zenoh_opaque.h:
- zc_owned_matching_listener_t!#unstable
- z_owned_subscriber_t!
- z_loaned_subscriber_t!
- zc_owned_liveliness_token_t!#unstable
- zc_loaned_liveliness_token_t!#unstable
- z_owned_liveliness_token_t!#unstable
- z_loaned_liveliness_token_t!#unstable
- ze_owned_publication_cache_t!#unstable
- z_owned_mutex_t!
- z_loaned_mutex_t!
Expand Down
24 changes: 12 additions & 12 deletions src/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,38 @@ use zenoh::{
};

use crate::{
opaque_types::{zc_loaned_liveliness_token_t, zc_owned_liveliness_token_t},
opaque_types::{z_loaned_liveliness_token_t, z_owned_liveliness_token_t},
result,
transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType},
z_closure_reply_call, z_closure_reply_loan, z_closure_sample_call, z_closure_sample_loan,
z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_reply_t, z_moved_closure_sample_t,
z_owned_subscriber_t, zc_moved_liveliness_token_t,
z_owned_subscriber_t, z_moved_liveliness_token_t,
};
decl_c_type!(
owned(zc_owned_liveliness_token_t, option LivelinessToken),
loaned(zc_loaned_liveliness_token_t),
owned(z_owned_liveliness_token_t, option LivelinessToken),
loaned(z_loaned_liveliness_token_t),
);

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Constructs liveliness token in its gravestone state.
#[no_mangle]
pub extern "C" fn zc_internal_liveliness_token_null(
this_: &mut MaybeUninit<zc_owned_liveliness_token_t>,
pub extern "C" fn z_internal_liveliness_token_null(
this_: &mut MaybeUninit<z_owned_liveliness_token_t>,
) {
this_.as_rust_type_mut_uninit().write(None);
}

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise.
#[no_mangle]
pub extern "C" fn zc_internal_liveliness_token_check(this_: &zc_owned_liveliness_token_t) -> bool {
pub extern "C" fn z_internal_liveliness_token_check(this_: &z_owned_liveliness_token_t) -> bool {
this_.as_rust_type_ref().is_some()
}

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Undeclares liveliness token, frees memory and resets it to a gravestone state.
#[no_mangle]
pub extern "C" fn z_liveliness_token_drop(this_: &mut zc_moved_liveliness_token_t) {
pub extern "C" fn z_liveliness_token_drop(this_: &mut z_moved_liveliness_token_t) {
let _ = this_.take_rust_type();
}

Expand All @@ -78,8 +78,8 @@ pub extern "C" fn z_liveliness_token_options_default(
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn z_liveliness_token_loan(
this: &zc_owned_liveliness_token_t,
) -> &zc_loaned_liveliness_token_t {
this: &z_owned_liveliness_token_t,
) -> &z_loaned_liveliness_token_t {
this.as_rust_type_ref()
.as_ref()
.unwrap_unchecked()
Expand All @@ -99,7 +99,7 @@ pub unsafe extern "C" fn z_liveliness_token_loan(
#[no_mangle]
pub extern "C" fn z_liveliness_declare_token(
session: &z_loaned_session_t,
token: &mut MaybeUninit<zc_owned_liveliness_token_t>,
token: &mut MaybeUninit<z_owned_liveliness_token_t>,
key_expr: &z_loaned_keyexpr_t,
_options: Option<&z_liveliness_token_options_t>,
) -> result::z_result_t {
Expand All @@ -123,7 +123,7 @@ pub extern "C" fn z_liveliness_declare_token(
/// @brief Destroys a liveliness token, notifying subscribers of its destruction.
#[no_mangle]
pub extern "C" fn z_liveliness_undeclare_token(
this: &mut zc_moved_liveliness_token_t,
this: &mut z_moved_liveliness_token_t,
) -> result::z_result_t {
if let Some(token) = this.take_rust_type() {
if let Err(e) = token.undeclare().wait() {
Expand Down
4 changes: 2 additions & 2 deletions tests/z_api_liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void test_liveliness_sub() {
z_liveliness_declare_subscriber(z_loan(s2), &sub, z_loan(k), z_move(closure), NULL);

z_sleep_s(1);
zc_owned_liveliness_token_t t1, t2;
z_owned_liveliness_token_t t1, t2;
z_liveliness_declare_token(z_loan(s1), &t1, z_loan(k1), NULL);
z_liveliness_declare_token(z_loan(s1), &t2, z_loan(k2), NULL);

Expand Down Expand Up @@ -109,7 +109,7 @@ void test_liveliness_get() {
z_open(&s2, z_move(c2), NULL);

z_sleep_s(1);
zc_owned_liveliness_token_t t1;
z_owned_liveliness_token_t t1;
z_liveliness_declare_token(z_loan(s1), &t1, z_loan(k1), NULL);
z_sleep_s(1);

Expand Down

0 comments on commit 50e5618

Please sign in to comment.