From 6822ee23da5f3843361ca3b68b04a13b88854d39 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Wed, 9 Oct 2024 16:49:01 +0200 Subject: [PATCH] add ze_publication_cache_declare_background; rename z_declare_queryable into z_queryable_declare; --- Cargo.lock | 60 ++++++++++----------- build-resources/opaque-types/Cargo.lock | 60 ++++++++++----------- docs/api.rst | 3 +- docs/examples.rst | 2 +- examples/z_queryable.c | 2 +- examples/z_queryable_shm.c | 2 +- examples/z_queryable_with_channels.c | 2 +- include/zenoh_commons.h | 68 +++++++++++++++--------- src/publication_cache.rs | 70 ++++++++++++++++++------- src/queryable.rs | 4 +- tests/z_api_alignment_test.c | 2 +- tests/z_api_double_drop_test.c | 2 +- tests/z_int_queryable_attachment_test.c | 2 +- tests/z_int_queryable_test.c | 2 +- tests/z_leak_queryable_get_test.c | 2 +- 15 files changed, 166 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed7ec3715..5b6fcd023 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "ahash", "async-trait", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "zenoh-collections", ] @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "tracing", "uhlc", @@ -3840,12 +3840,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "json5", "num_cpus", @@ -3866,7 +3866,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "lazy_static", "tokio", @@ -3877,7 +3877,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "aes", "hmac", @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "bincode", "flume", @@ -3907,7 +3907,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -3921,7 +3921,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "flume", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "base64 0.22.1", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "zenoh-link-serial" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "tokio", @@ -4007,7 +4007,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "socket2 0.5.7", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "base64 0.22.1", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "socket2 0.5.7", @@ -4070,7 +4070,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixpipe" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "advisory-lock", "async-trait", @@ -4092,7 +4092,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "nix 0.29.0", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "zenoh-link-vsock" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "libc", @@ -4128,7 +4128,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "futures-util", @@ -4148,7 +4148,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "proc-macro2", "quote", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "git-version", "libloading", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "const_format", "rand", @@ -4189,7 +4189,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "anyhow", ] @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "lazy_static", "ron", @@ -4210,7 +4210,7 @@ dependencies = [ [[package]] name = "zenoh-shm" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "advisory-lock", "async-trait", @@ -4233,7 +4233,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "event-listener 5.3.1", "futures", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "futures", "tokio", @@ -4259,7 +4259,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "crossbeam-utils", @@ -4293,7 +4293,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "const_format", diff --git a/build-resources/opaque-types/Cargo.lock b/build-resources/opaque-types/Cargo.lock index 7a6e0745e..8d9cbb6d1 100644 --- a/build-resources/opaque-types/Cargo.lock +++ b/build-resources/opaque-types/Cargo.lock @@ -3132,7 +3132,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "ahash", "async-trait", @@ -3182,7 +3182,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "zenoh-collections", ] @@ -3190,7 +3190,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "tracing", "uhlc", @@ -3202,12 +3202,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "json5", "num_cpus", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "lazy_static", "tokio", @@ -3239,7 +3239,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "aes", "hmac", @@ -3252,7 +3252,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "bincode", "flume", @@ -3269,7 +3269,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "hashbrown", "keyed-set", @@ -3283,7 +3283,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3303,7 +3303,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "flume", @@ -3326,7 +3326,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "base64 0.22.1", @@ -3351,7 +3351,7 @@ dependencies = [ [[package]] name = "zenoh-link-serial" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "tokio", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "socket2", @@ -3386,7 +3386,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "base64 0.22.1", @@ -3413,7 +3413,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "socket2", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixpipe" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "advisory-lock", "async-trait", @@ -3454,7 +3454,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "nix 0.29.0", @@ -3472,7 +3472,7 @@ dependencies = [ [[package]] name = "zenoh-link-vsock" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "libc", @@ -3490,7 +3490,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "futures-util", @@ -3510,7 +3510,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "proc-macro2", "quote", @@ -3521,7 +3521,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "git-version", "libloading", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "const_format", "rand", @@ -3551,7 +3551,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "anyhow", ] @@ -3559,7 +3559,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "lazy_static", "ron", @@ -3572,7 +3572,7 @@ dependencies = [ [[package]] name = "zenoh-shm" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "advisory-lock", "async-trait", @@ -3595,7 +3595,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "event-listener", "futures", @@ -3608,7 +3608,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "futures", "tokio", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "crossbeam-utils", @@ -3655,7 +3655,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d3768b87d23599f791af2de0c0d8fbe41f079431" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#b1f237d400fc5ba25f5ae80d03aa4dbaee73e72a" dependencies = [ "async-trait", "const_format", diff --git a/docs/api.rst b/docs/api.rst index 617a96054..73f53e111 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -686,7 +686,7 @@ Types Functions --------- -.. doxygenfunction:: z_declare_queryable +.. doxygenfunction:: z_queryable_declare .. doxygenfunction:: z_queryable_declare_background .. doxygenfunction:: z_queryable_id @@ -865,6 +865,7 @@ Functions --------- .. doxygenfunction:: ze_publication_cache_declare +.. doxygenfunction:: ze_publication_cache_declare_background .. doxygenfunction:: ze_publication_cache_drop .. doxygenfunction:: ze_publication_cache_loan diff --git a/docs/examples.rst b/docs/examples.rst index ac9bb875b..dd9454d39 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -195,7 +195,7 @@ Queryable z_closure(&callback, query_handler, NULL, (void*)keyexpr); z_owned_queryable_t qable; - if (z_declare_queryable(&qable, z_loan(s), z_loan(key_expr), z_move(callback), NULL) < 0) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(key_expr), z_move(callback), NULL) < 0) { printf("Unable to create Zenoh queryable.\n"); exit(-1); } diff --git a/examples/z_queryable.c b/examples/z_queryable.c index 1d1da13f4..ca295f023 100644 --- a/examples/z_queryable.c +++ b/examples/z_queryable.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) { z_closure(&callback, query_handler, NULL, (void *)args.keyexpr); z_owned_queryable_t qable; - if (z_declare_queryable(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { printf("Unable to create queryable.\n"); exit(-1); } diff --git a/examples/z_queryable_shm.c b/examples/z_queryable_shm.c index b235490c9..260d731c3 100644 --- a/examples/z_queryable_shm.c +++ b/examples/z_queryable_shm.c @@ -119,7 +119,7 @@ int main(int argc, char **argv) { z_closure(&callback, query_handler, (void *)z_loan(provider), (void *)keyexpr); z_owned_queryable_t qable; - if (z_declare_queryable(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { printf("Unable to create queryable.\n"); exit(-1); } diff --git a/examples/z_queryable_with_channels.c b/examples/z_queryable_with_channels.c index 22269bc15..6238dbcae 100644 --- a/examples/z_queryable_with_channels.c +++ b/examples/z_queryable_with_channels.c @@ -52,7 +52,7 @@ int main(int argc, char** argv) { z_fifo_channel_query_new(&closure, &handler, 16); z_owned_queryable_t qable; - if (z_declare_queryable(&qable, z_loan(s), z_loan(ke), z_move(closure), NULL) < 0) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(ke), z_move(closure), NULL) < 0) { printf("Unable to create queryable.\n"); exit(-1); } diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 4b0aecf43..a038e6b04 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -605,15 +605,6 @@ typedef struct z_moved_condvar_t { typedef struct z_moved_config_t { struct z_owned_config_t _this; } z_moved_config_t; -/** - * Options passed to the `z_declare_queryable()` function. - */ -typedef struct z_queryable_options_t { - /** - * The completeness of the Queryable. - */ - bool complete; -} z_queryable_options_t; /** * Options passed to the `z_delete()` function. */ @@ -962,6 +953,15 @@ typedef struct z_query_reply_err_options_t { */ struct z_moved_encoding_t *encoding; } z_query_reply_err_options_t; +/** + * Options passed to the `z_queryable_declare()` function. + */ +typedef struct z_queryable_options_t { + /** + * The completeness of the Queryable. + */ + bool complete; +} z_queryable_options_t; typedef struct z_moved_queryable_t { struct z_owned_queryable_t _this; } z_moved_queryable_t; @@ -1939,23 +1939,6 @@ ZENOHC_API z_result_t z_declare_keyexpr(struct z_owned_keyexpr_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr); -/** - * Constructs a Queryable for the given key expression. - * - * @param this_: An uninitialized memory location where queryable will be constructed. - * @param session: The zenoh session. - * @param key_expr: The key expression the Queryable will reply to. - * @param callback: The callback function that will be called each time a matching query is received. Its ownership is passed to queryable. - * @param options: Options for the queryable. - * - * @return 0 in case of success, negative error code otherwise (in this case ) - */ -ZENOHC_API -z_result_t z_declare_queryable(struct z_owned_queryable_t *this_, - const struct z_loaned_session_t *session, - const struct z_loaned_keyexpr_t *key_expr, - struct z_moved_closure_query_t *callback, - struct z_queryable_options_t *options); /** * Sends request to delete data on specified key expression (used when working with Zenoh storages ). * @@ -3586,6 +3569,23 @@ ZENOHC_API void z_query_reply_options_default(struct z_query_reply_options_t *th * Create a default `z_query_target_t`. */ ZENOHC_API enum z_query_target_t z_query_target_default(void); +/** + * Constructs a Queryable for the given key expression. + * + * @param this_: An uninitialized memory location where queryable will be constructed. + * @param session: The zenoh session. + * @param key_expr: The key expression the Queryable will reply to. + * @param callback: The callback function that will be called each time a matching query is received. Its ownership is passed to queryable. + * @param options: Options for the queryable. + * + * @return 0 in case of success, negative error code otherwise (in this case ) + */ +ZENOHC_API +z_result_t z_queryable_declare(struct z_owned_queryable_t *this_, + const struct z_loaned_session_t *session, + const struct z_loaned_keyexpr_t *key_expr, + struct z_moved_closure_query_t *callback, + struct z_queryable_options_t *options); /** * Declares a background queryable for a given keyexpr. The queryable callback will be be called * to proccess incoming queries until the corresponding session is closed or dropped. @@ -5467,6 +5467,22 @@ z_result_t ze_publication_cache_declare(ze_owned_publication_cache_t *this_, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Declares a background publication cache. It will function in background until the corresponding session is closed or dropped. + * + * @param session: A Zenoh session. + * @param key_expr: The key expression to publish to. + * @param options: Additional options for the publication cache. + * + * @returns 0 in case of success, negative error code otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +z_result_t ze_publication_cache_declare_background(const struct z_loaned_session_t *session, + const struct z_loaned_keyexpr_t *key_expr, + struct ze_publication_cache_options_t *options); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops publication cache and resets it to its gravestone state. diff --git a/src/publication_cache.rs b/src/publication_cache.rs index 4af68ef05..d689c30f4 100644 --- a/src/publication_cache.rs +++ b/src/publication_cache.rs @@ -15,7 +15,7 @@ use std::{mem::MaybeUninit, ptr::null}; use zenoh::Wait; -use zenoh_ext::SessionExt; +use zenoh_ext::{PublicationCacheBuilder, SessionExt}; use crate::{ result, @@ -69,24 +69,11 @@ decl_c_type!( loaned(ze_loaned_publication_cache_t), ); -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs and declares a publication cache. -/// -/// @param this_: An uninitialized location in memory where publication cache will be constructed. -/// @param session: A Zenoh session. -/// @param key_expr: The key expression to publish to. -/// @param options: Additional options for the publication cache. -/// -/// @returns 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_publication_cache_declare( - this: &mut MaybeUninit, - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut ze_publication_cache_options_t>, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); +fn _declare_publication_cache_inner<'a, 'b, 'c>( + session: &'a z_loaned_session_t, + key_expr: &'b z_loaned_keyexpr_t, + options: Option<&'c mut ze_publication_cache_options_t>, +) -> PublicationCacheBuilder<'a, 'b, 'c> { let session = session.as_rust_type_ref(); let key_expr = key_expr.as_rust_type_ref(); let mut p = session.declare_publication_cache(key_expr); @@ -105,6 +92,27 @@ pub extern "C" fn ze_publication_cache_declare( p = p.queryable_prefix(queryable_prefix.clone()); } } + p +} + +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Constructs and declares a publication cache. +/// +/// @param this_: An uninitialized location in memory where publication cache will be constructed. +/// @param session: A Zenoh session. +/// @param key_expr: The key expression to publish to. +/// @param options: Additional options for the publication cache. +/// +/// @returns 0 in case of success, negative error code otherwise. +#[no_mangle] +pub extern "C" fn ze_publication_cache_declare( + this: &mut MaybeUninit, + session: &z_loaned_session_t, + key_expr: &z_loaned_keyexpr_t, + options: Option<&mut ze_publication_cache_options_t>, +) -> result::z_result_t { + let this = this.as_rust_type_mut_uninit(); + let p = _declare_publication_cache_inner(session, key_expr, options); match p.wait() { Ok(publication_cache) => { this.write(Some(publication_cache)); @@ -118,6 +126,30 @@ pub extern "C" fn ze_publication_cache_declare( } } +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Declares a background publication cache. It will function in background until the corresponding session is closed or dropped. +/// +/// @param session: A Zenoh session. +/// @param key_expr: The key expression to publish to. +/// @param options: Additional options for the publication cache. +/// +/// @returns 0 in case of success, negative error code otherwise. +#[no_mangle] +pub extern "C" fn ze_publication_cache_declare_background( + session: &z_loaned_session_t, + key_expr: &z_loaned_keyexpr_t, + options: Option<&mut ze_publication_cache_options_t>, +) -> result::z_result_t { + let p = _declare_publication_cache_inner(session, key_expr, options); + match p.background().wait() { + Ok(_) => result::Z_OK, + Err(e) => { + tracing::error!("{}", e); + result::Z_EGENERIC + } + } +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Constructs a publication cache in a gravestone state. #[no_mangle] diff --git a/src/queryable.rs b/src/queryable.rs index 260836589..d9598c3ae 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -96,7 +96,7 @@ pub extern "C" fn z_query_clone(dst: &mut MaybeUninit, this_: & .write(Some(this_.as_rust_type_ref().clone())); } -/// Options passed to the `z_declare_queryable()` function. +/// Options passed to the `z_queryable_declare()` function. #[allow(non_camel_case_types)] #[repr(C)] pub struct z_queryable_options_t { @@ -242,7 +242,7 @@ fn _declare_queryable_inner<'a, 'b>( /// /// @return 0 in case of success, negative error code otherwise (in this case ) #[no_mangle] -pub extern "C" fn z_declare_queryable( +pub extern "C" fn z_queryable_declare( this: &mut MaybeUninit, session: &z_loaned_session_t, key_expr: &z_loaned_keyexpr_t, diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index 0c10a7635..410f22952 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -314,7 +314,7 @@ int main(int argc, char **argv) { z_queryable_options_t _ret_qle_opt; z_queryable_options_default(&_ret_qle_opt); z_owned_queryable_t qle; - z_declare_queryable(&qle, z_loan(s1), z_loan(s1_key), z_move(_ret_closure_query), &_ret_qle_opt); + z_queryable_declare(&qle, z_loan(s1), z_loan(s1_key), z_move(_ret_closure_query), &_ret_qle_opt); assert(z_internal_check(qle)); z_sleep_s(SLEEP); diff --git a/tests/z_api_double_drop_test.c b/tests/z_api_double_drop_test.c index 807681eb9..aa58603bc 100644 --- a/tests/z_api_double_drop_test.c +++ b/tests/z_api_double_drop_test.c @@ -110,7 +110,7 @@ void test_queryable() { z_view_keyexpr_t keyexpr; z_view_keyexpr_from_str(&keyexpr, URL); z_owned_queryable_t queryable; - z_declare_queryable(&queryable, z_loan(s), z_loan(keyexpr), z_move(callback), NULL); + z_queryable_declare(&queryable, z_loan(s), z_loan(keyexpr), z_move(callback), NULL); assert(z_internal_check(queryable)); z_drop(z_move(queryable)); assert(!z_internal_check(queryable)); diff --git a/tests/z_int_queryable_attachment_test.c b/tests/z_int_queryable_attachment_test.c index 920b2f543..edb8fa656 100644 --- a/tests/z_int_queryable_attachment_test.c +++ b/tests/z_int_queryable_attachment_test.c @@ -142,7 +142,7 @@ int run_queryable() { z_view_keyexpr_from_str(&ke, keyexpr); z_owned_queryable_t qable; - if (z_declare_queryable(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { printf("Unable to create queryable.\n"); return -1; } diff --git a/tests/z_int_queryable_test.c b/tests/z_int_queryable_test.c index b34e7cc66..a033da90d 100644 --- a/tests/z_int_queryable_test.c +++ b/tests/z_int_queryable_test.c @@ -74,7 +74,7 @@ int run_queryable() { z_closure(&callback, query_handler, NULL, (void *)keyexpr); z_owned_queryable_t qable; ; - if (z_declare_queryable(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) != Z_OK) { + if (z_queryable_declare(&qable, z_loan(s), z_loan(ke), z_move(callback), NULL) != Z_OK) { printf("Unable to create queryable.\n"); return -1; } diff --git a/tests/z_leak_queryable_get_test.c b/tests/z_leak_queryable_get_test.c index 6b1c4e133..ee5d0bda1 100644 --- a/tests/z_leak_queryable_get_test.c +++ b/tests/z_leak_queryable_get_test.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) { z_owned_closure_query_t callback; z_closure(&callback, query_handler, NULL, NULL); z_owned_queryable_t queryable; - z_declare_queryable(&queryable, z_loan(queryable_session), z_loan(queryable_keyexpr), z_move(callback), NULL); + z_queryable_declare(&queryable, z_loan(queryable_session), z_loan(queryable_keyexpr), z_move(callback), NULL); z_view_keyexpr_t get_keyexpr; z_view_keyexpr_from_str(&get_keyexpr, GET_KEY_EXPR);