From d69a33389996bb975fa4391750d6b8a75fc0c265 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Wed, 9 Oct 2024 12:39:08 +0200 Subject: [PATCH] examples update --- examples/unix/c11/z_pong.c | 5 +---- examples/unix/c11/z_sub_thr.c | 4 +--- examples/unix/c99/z_pong.c | 8 +++----- examples/windows/z_pong.c | 7 ++----- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index ab4795531..901ed4ba5 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -60,8 +60,7 @@ int main(int argc, char** argv) { z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_owned_closure_sample_t respond; z_closure(&respond, callback, drop, (void*)(&pub)); - z_owned_subscriber_t sub; - if (z_declare_subscriber(&sub, z_loan(session), z_loan(ping), z_move(respond), NULL) < 0) { + if (z_declare_background_subscriber(z_loan(session), z_loan(ping), z_move(respond), NULL) < 0) { printf("Unable to declare subscriber for key expression.\n"); return -1; } @@ -69,8 +68,6 @@ int main(int argc, char** argv) { while (getchar() != 'q') { } - z_drop(z_move(sub)); - z_drop(z_move(session)); } #else diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index 8ba7eb81f..1a0d0075f 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -95,10 +95,9 @@ int main(int argc, char **argv) { z_stats_t *context = z_stats_make(); z_owned_closure_sample_t callback; z_closure(&callback, on_sample, drop_stats, (void *)context); - z_owned_subscriber_t sub; z_view_keyexpr_t ke; z_view_keyexpr_from_str(&ke, keyexpr); - if (z_declare_subscriber(&sub, z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { + if (z_declare_background_subscriber(z_loan(s), z_loan(ke), z_move(callback), NULL) < 0) { printf("Unable to create subscriber.\n"); exit(-1); } @@ -109,7 +108,6 @@ int main(int argc, char **argv) { } // Clean up - z_drop(z_move(sub)); z_drop(z_move(s)); exit(0); } diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 1c849b8e3..30e91799a 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -63,9 +63,9 @@ int main(int argc, char** argv) { z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_owned_closure_sample_t respond; z_closure_sample(&respond, callback, drop, (void*)(&pub)); - z_owned_subscriber_t sub; - if (z_declare_subscriber(&sub, z_session_loan(&session), z_view_keyexpr_loan(&ping), - z_closure_sample_move(&respond), NULL) < 0) { + + if (z_declare_background_subscriber(z_session_loan(&session), z_view_keyexpr_loan(&ping), + z_closure_sample_move(&respond), NULL) < 0) { printf("Unable to declare subscriber for key expression.\n"); return -1; } @@ -73,8 +73,6 @@ int main(int argc, char** argv) { while (getchar() != 'q') { } - z_subscriber_drop(z_subscriber_move(&sub)); - z_session_drop(z_session_move(&session)); } #else diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index ab4795531..fae246b2f 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -60,17 +60,14 @@ int main(int argc, char** argv) { z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_owned_closure_sample_t respond; z_closure(&respond, callback, drop, (void*)(&pub)); - z_owned_subscriber_t sub; - if (z_declare_subscriber(&sub, z_loan(session), z_loan(ping), z_move(respond), NULL) < 0) { + + if (z_declare_background_subscriber(z_loan(session), z_loan(ping), z_move(respond), NULL) < 0) { printf("Unable to declare subscriber for key expression.\n"); return -1; } while (getchar() != 'q') { } - - z_drop(z_move(sub)); - z_drop(z_move(session)); } #else