Skip to content

Commit

Permalink
Rename ze_close_publication_cache to ze_undeclare_publication_cache
Browse files Browse the repository at this point in the history
+ macros and examples update
  • Loading branch information
sashacmc committed Nov 17, 2023
1 parent 57eca8a commit a3e39a7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion examples/z_pub_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(int argc, char **argv) {
printf("Declaring publication cache on '%s'...\n", keyexpr);
ze_owned_publication_cache_t pub_cache =
ze_declare_publication_cache(z_loan(s), z_keyexpr(keyexpr), &pub_cache_opts);
if (!ze_publication_cache_check(&pub_cache)) {
if (!z_check(pub_cache)) {
printf("Unable to declare publication cache for key expression!\n");
exit(-1);
}
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -2046,11 +2046,6 @@ void zc_shmbuf_set_length(const struct zc_owned_shmbuf_t *buf,
uintptr_t len);
ZENOHC_API enum zcu_locality_t zcu_locality_default(void);
ZENOHC_API enum zcu_reply_keyexpr_t zcu_reply_keyexpr_default(void);
/**
* Closes the given :c:type:`ze_owned_publication_cache_t`, droping it and invalidating it for double-drop safety.
*/
ZENOHC_API
int8_t ze_close_publication_cache(struct ze_owned_publication_cache_t *pub_cache);
/**
* Declares a Publication Cache.
*
Expand Down Expand Up @@ -2143,6 +2138,11 @@ ZENOHC_API struct ze_owned_querying_subscriber_t ze_querying_subscriber_null(voi
* Constructs the default value for :c:type:`ze_querying_subscriber_options_t`.
*/
ZENOHC_API struct ze_querying_subscriber_options_t ze_querying_subscriber_options_default(void);
/**
* Closes the given :c:type:`ze_owned_publication_cache_t`, droping it and invalidating it for double-drop safety.
*/
ZENOHC_API
int8_t ze_undeclare_publication_cache(struct ze_owned_publication_cache_t *pub_cache);
/**
* Undeclares the given :c:type:`ze_owned_querying_subscriber_t`, droping it and invalidating it for double-drop safety.
*/
Expand Down
90 changes: 46 additions & 44 deletions include/zenoh_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
)(&x)

#define z_drop(x) \
_Generic((x), z_owned_session_t * : z_close, \
z_owned_publisher_t * : z_undeclare_publisher, \
z_owned_keyexpr_t * : z_keyexpr_drop, \
z_owned_config_t * : z_config_drop, \
z_owned_scouting_config_t * : z_scouting_config_drop, \
z_owned_pull_subscriber_t * : z_undeclare_pull_subscriber, \
z_owned_subscriber_t * : z_undeclare_subscriber, \
z_owned_queryable_t * : z_undeclare_queryable, \
z_owned_encoding_t * : z_encoding_drop, \
z_owned_reply_t * : z_reply_drop, \
z_owned_hello_t * : z_hello_drop, \
z_owned_str_t * : z_str_drop, \
z_owned_closure_sample_t * : z_closure_sample_drop, \
z_owned_closure_query_t * : z_closure_query_drop, \
z_owned_closure_reply_t * : z_closure_reply_drop, \
z_owned_closure_hello_t * : z_closure_hello_drop, \
z_owned_closure_zid_t * : z_closure_zid_drop, \
z_owned_reply_channel_closure_t * : z_reply_channel_closure_drop, \
z_owned_reply_channel_t * : z_reply_channel_drop, \
zc_owned_payload_t * : zc_payload_drop, \
zc_owned_shmbuf_t * : zc_shmbuf_drop, \
zc_owned_shm_manager_t * : zc_shm_manager_drop, \
zc_owned_liveliness_token_t * : zc_liveliness_undeclare_token, \
ze_owned_publication_cache_t* : ze_close_publication_cache, \
ze_owned_querying_subscriber_t* : ze_undeclare_querying_subscriber \
_Generic((x), z_owned_session_t * : z_close, \
z_owned_publisher_t * : z_undeclare_publisher, \
z_owned_keyexpr_t * : z_keyexpr_drop, \
z_owned_config_t * : z_config_drop, \
z_owned_scouting_config_t * : z_scouting_config_drop, \
z_owned_pull_subscriber_t * : z_undeclare_pull_subscriber, \
z_owned_subscriber_t * : z_undeclare_subscriber, \
z_owned_queryable_t * : z_undeclare_queryable, \
z_owned_encoding_t * : z_encoding_drop, \
z_owned_reply_t * : z_reply_drop, \
z_owned_hello_t * : z_hello_drop, \
z_owned_str_t * : z_str_drop, \
z_owned_closure_sample_t * : z_closure_sample_drop, \
z_owned_closure_query_t * : z_closure_query_drop, \
z_owned_closure_reply_t * : z_closure_reply_drop, \
z_owned_closure_hello_t * : z_closure_hello_drop, \
z_owned_closure_zid_t * : z_closure_zid_drop, \
z_owned_reply_channel_closure_t * : z_reply_channel_closure_drop, \
z_owned_reply_channel_t * : z_reply_channel_drop, \
zc_owned_payload_t * : zc_payload_drop, \
zc_owned_shmbuf_t * : zc_shmbuf_drop, \
zc_owned_shm_manager_t * : zc_shm_manager_drop, \
zc_owned_liveliness_token_t * : zc_liveliness_undeclare_token, \
ze_owned_publication_cache_t * : ze_undeclare_publication_cache, \
ze_owned_querying_subscriber_t * : ze_undeclare_querying_subscriber \
)(x)

#define z_null(x) (*x = \
Expand All @@ -66,29 +66,31 @@
zc_owned_payload_t * : zc_payload_null, \
zc_owned_shmbuf_t * : zc_shmbuf_null, \
zc_owned_shm_manager_t * : zc_shm_manager_null, \
ze_owned_publication_cache_t * : ze_publication_cache_null, \
zc_owned_liveliness_token_t * : zc_liveliness_token_null \
)())

#define z_check(x) \
_Generic((x), z_owned_session_t : z_session_check, \
z_owned_publisher_t : z_publisher_check, \
z_owned_keyexpr_t : z_keyexpr_check, \
z_keyexpr_t : z_keyexpr_is_initialized, \
z_owned_config_t : z_config_check, \
z_owned_scouting_config_t : z_scouting_config_check, \
z_bytes_t : z_bytes_check, \
z_owned_subscriber_t : z_subscriber_check, \
z_owned_pull_subscriber_t : z_pull_subscriber_check, \
z_owned_queryable_t : z_queryable_check, \
z_owned_encoding_t : z_encoding_check, \
z_owned_reply_t : z_reply_check, \
z_owned_hello_t : z_hello_check, \
z_owned_str_t : z_str_check, \
zc_owned_payload_t : zc_payload_check, \
zc_owned_shmbuf_t : zc_shmbuf_check, \
zc_owned_shm_manager_t : zc_shm_manager_check, \
zc_owned_liveliness_token_t : zc_liveliness_token_check, \
ze_owned_querying_subscriber_t: ze_querying_subscriber_check \
_Generic((x), z_owned_session_t : z_session_check, \
z_owned_publisher_t : z_publisher_check, \
z_owned_keyexpr_t : z_keyexpr_check, \
z_keyexpr_t : z_keyexpr_is_initialized, \
z_owned_config_t : z_config_check, \
z_owned_scouting_config_t : z_scouting_config_check, \
z_bytes_t : z_bytes_check, \
z_owned_subscriber_t : z_subscriber_check, \
z_owned_pull_subscriber_t : z_pull_subscriber_check, \
z_owned_queryable_t : z_queryable_check, \
z_owned_encoding_t : z_encoding_check, \
z_owned_reply_t : z_reply_check, \
z_owned_hello_t : z_hello_check, \
z_owned_str_t : z_str_check, \
zc_owned_payload_t : zc_payload_check, \
zc_owned_shmbuf_t : zc_shmbuf_check, \
zc_owned_shm_manager_t : zc_shm_manager_check, \
zc_owned_liveliness_token_t : zc_liveliness_token_check, \
ze_owned_publication_cache_t : ze_publication_cache_check, \
ze_owned_querying_subscriber_t : ze_querying_subscriber_check \
)(&x)

#define z_call(x, ...) \
Expand Down
4 changes: 3 additions & 1 deletion src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ pub extern "C" fn ze_publication_cache_check(pub_cache: &ze_owned_publication_ca
/// Closes the given :c:type:`ze_owned_publication_cache_t`, droping it and invalidating it for double-drop safety.
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub extern "C" fn ze_close_publication_cache(pub_cache: &mut ze_owned_publication_cache_t) -> i8 {
pub extern "C" fn ze_undeclare_publication_cache(
pub_cache: &mut ze_owned_publication_cache_t,
) -> i8 {
if let Some(p) = pub_cache.as_mut().take() {
if let Err(e) = p.close().res_sync() {
log::error!("{}", e);
Expand Down

0 comments on commit a3e39a7

Please sign in to comment.