Skip to content

Commit

Permalink
examples update
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Oct 9, 2024
1 parent c2a6e89 commit d69a333
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
5 changes: 1 addition & 4 deletions examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions examples/unix/c11/z_sub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -109,7 +108,6 @@ int main(int argc, char **argv) {
}

// Clean up
z_drop(z_move(sub));
z_drop(z_move(s));
exit(0);
}
Expand Down
8 changes: 3 additions & 5 deletions examples/unix/c99/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ 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;
}

while (getchar() != 'q') {
}

z_subscriber_drop(z_subscriber_move(&sub));

z_session_drop(z_session_move(&session));
}
#else
Expand Down
7 changes: 2 additions & 5 deletions examples/windows/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d69a333

Please sign in to comment.