Skip to content

Commit

Permalink
Rework z_closure
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Apr 30, 2024
1 parent 7ed9508 commit dab7394
Show file tree
Hide file tree
Showing 62 changed files with 202 additions and 137 deletions.
3 changes: 2 additions & 1 deletion examples/arduino/z_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void loop() {
if (strcmp(VALUE, "") != 0) {
opts.value.payload = _z_bytes_wrap((const uint8_t *)VALUE, strlen(VALUE));
}
z_owned_closure_reply_t callback = z_closure_reply(reply_handler, reply_dropper, NULL);
z_owned_closure_reply_t callback;
z_closure_reply(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_session_loan(&s), z_keyexpr(KEYEXPR), "", z_closure_reply_move(&callback), &opts) < 0) {
Serial.println("Unable to send query.");
}
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_pull.ino
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ void setup() {
Serial.print(KEYEXPR);
Serial.println(" ...");
// @TODO
// z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
// z_owned_closure_sample_t callback;
// z_closure_sample(&callback, data_handler, NULL, NULL);
// @TODO
// sub = z_declare_pull_subscriber(z_session_loan(&s), z_keyexpr(KEYEXPR), z_closure_sample_move(&callback), NULL);
// if (!z_pull_subscriber_check(&sub)) {
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void setup() {
Serial.print("Declaring Queryable on ");
Serial.print(KEYEXPR);
Serial.println(" ...");
z_owned_closure_query_t callback = z_closure_query(query_handler, NULL, NULL);
z_owned_closure_query_t callback;
z_closure_query(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable =
z_declare_queryable(z_session_loan(&s), z_keyexpr(KEYEXPR), z_closure_query_move(&callback), NULL);
if (!z_queryable_check(&qable)) {
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_scout.ino
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ void loop() {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure_hello(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));
}
3 changes: 2 additions & 1 deletion examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void setup() {
Serial.print("Declaring Subscriber on ");
Serial.print(KEYEXPR);
Serial.println(" ...");
z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
z_owned_closure_sample_t callback;
z_closure_sample(&callback, data_handler, NULL, NULL);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_session_loan(&s), z_keyexpr(KEYEXPR), z_closure_sample_move(&callback), NULL) <
0) {
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ void app_main() {
if (strcmp(VALUE, "") != 0) {
opts.value.payload = _z_bytes_wrap((const uint8_t *)VALUE, strlen(VALUE));
}
z_owned_closure_reply_t callback = z_closure(reply_handler, reply_dropper);
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
if (z_get(z_loan(s), z_keyexpr(KEYEXPR), "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ void app_main() {
zp_start_lease_task(z_loan(s), NULL);

// @TODO
// z_owned_closure_sample_t callback = z_closure(data_handler);
// z_owned_closure_sample_t callback;
// z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...", KEYEXPR);
// @TODO
// z_owned_pull_subscriber_t sub = z_declare_pull_subscriber(z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ void app_main() {

// Declare Zenoh queryable
printf("Declaring Queryable on %s...", KEYEXPR);
z_owned_closure_query_t callback = z_closure(query_handler);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_owned_queryable_t qable = z_declare_queryable(z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL);
if (!z_check(qable)) {
printf("Unable to declare queryable.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ void app_main() {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure_hello(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));
}
3 changes: 2 additions & 1 deletion examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ void app_main() {
zp_start_lease_task(z_loan(s), NULL);

printf("Declaring Subscriber on '%s'...", KEYEXPR);
z_owned_closure_sample_t callback = z_closure(data_handler);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL) < 0) {
printf("Unable to declare subscriber.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void app_main(void) {
if (strcmp(VALUE, "") != 0) {
opts.value.payload = _z_bytes_wrap((const uint8_t *)VALUE, strlen(VALUE));
}
z_owned_closure_reply_t callback = z_closure(reply_handler, reply_dropper);
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
if (z_get(z_loan(s), ke, "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void app_main(void) {
}

// @TODO
// z_owned_closure_sample_t callback = z_closure(data_handler);
// z_owned_closure_sample_t callback;
// z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...\n", KEYEXPR);
// @TODO
// z_owned_pull_subscriber_t sub = z_declare_pull_subscriber(z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL);
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void app_main(void) {
}

printf("Creating Queryable on '%s'...\n", KEYEXPR);
z_owned_closure_query_t callback = z_closure(query_handler);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_owned_queryable_t qable = z_declare_queryable(z_loan(s), ke, z_move(callback), NULL);
if (!z_check(qable)) {
printf("Unable to create queryable.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ void app_main(void) {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_move(config), z_move(closure));
}
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void app_main(void) {
return;
}

z_owned_closure_sample_t callback = z_closure(data_handler);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...\n", KEYEXPR);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL) < 0) {
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void app_main(void) {
return;
}

z_owned_closure_sample_t callback = z_closure(data_handler);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...\n", KEYEXPR);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(KEYEXPR), z_move(callback), NULL) < 0) {
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ int main(int argc, char **argv) {
if (strcmp(VALUE, "") != 0) {
opts.value.payload = _z_bytes_wrap((const uint8_t *)VALUE, strlen(VALUE));
}
z_owned_closure_reply_t callback = z_closure_reply(reply_handler, reply_dropper, NULL);
z_owned_closure_reply_t callback;
z_closure_reply(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_session_loan(&s), z_keyexpr(KEYEXPR), "", z_closure_reply_move(&callback), &opts) < 0) {
printf("Unable to send query.\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int main(int argc, char **argv) {
zp_start_lease_task(z_session_loan(&s), NULL);

// @TODO
// z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
// z_owned_closure_sample_t callback;
// z_closure_sample(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...", KEYEXPR);
// @TODO
// z_owned_pull_subscriber_t sub =
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ int main(int argc, char **argv) {

// Declare Zenoh queryable
printf("Declaring Queryable on %s...", KEYEXPR);
z_owned_closure_query_t callback = z_closure_query(query_handler, NULL, NULL);
z_owned_closure_query_t callback;
z_closure_query(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable =
z_declare_queryable(z_session_loan(&s), z_keyexpr(KEYEXPR), z_closure_query_move(&callback), NULL);
if (!z_queryable_check(&qable)) {
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_scout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ int main(void) {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure_hello(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));

Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ int main(int argc, char **argv) {
zp_start_lease_task(z_session_loan(&s), NULL);

printf("Declaring Subscriber on '%s'...", KEYEXPR);
z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
z_owned_closure_sample_t callback;
z_closure_sample(&callback, data_handler, NULL, NULL);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_session_loan(&s), z_keyexpr(KEYEXPR), z_closure_sample_move(&callback), NULL) <
0) {
Expand Down
4 changes: 3 additions & 1 deletion examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ int main(int argc, char **argv) {
z_bytes_map_insert_by_alias(&map, z_bytes_from_str("hi"), z_bytes_from_str("there"));
opts.attachment = z_bytes_map_as_attachment(&map);
#endif
z_owned_closure_reply_t callback = z_closure(reply_handler, reply_dropper);

z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
if (z_get(z_loan(s), ke, "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return -1;
Expand Down
6 changes: 4 additions & 2 deletions examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ int main(int argc, char **argv) {
print_zid(&self_id, NULL);

printf("Routers IDs:\n");
z_owned_closure_zid_t callback = z_closure(print_zid);
z_owned_closure_zid_t callback;
z_closure(&callback, print_zid);
z_info_routers_zid(z_loan(s), z_move(callback));

// `callback` has been `z_move`d just above, so it's safe to reuse the variable,
// we'll just have to make sure we `z_move` it again to avoid mem-leaks.
printf("Peers IDs:\n");
z_owned_closure_zid_t callback2 = z_closure(print_zid);
z_owned_closure_zid_t callback2;
z_closure(&callback2, print_zid);
z_info_peers_zid(z_loan(s), z_move(callback2));

// Stop read and lease tasks for zenoh-pico
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ int main(int argc, char** argv) {
return -1;
}

z_owned_closure_sample_t respond = z_closure(callback, drop, NULL);
z_owned_closure_sample_t respond;
z_closure(&respond, callback, drop, NULL);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(session), pong, z_move(respond), NULL) < 0) {
printf("Unable to declare subscriber for key expression.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ int main(int argc, char** argv) {
}

z_keyexpr_t ping = z_keyexpr_unchecked("test/ping");
z_owned_closure_sample_t respond = z_closure(callback, drop, (void*)z_move(pub));
z_owned_closure_sample_t respond;
z_closure(&respond, callback, drop, (void*)z_move(pub));
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(session), ping, z_move(respond), NULL) < 0) {
printf("Unable to declare subscriber for key expression.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ int main(int argc, char **argv) {
}

printf("Creating Queryable on '%s'...\n", keyexpr);
z_owned_closure_query_t callback = z_closure(query_handler);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_owned_queryable_t qable = z_declare_queryable(z_loan(s), ke, z_move(callback), NULL);
if (!z_check(qable)) {
printf("Unable to create queryable.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ int main(int argc, char **argv) {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_move(config), z_move(closure));
sleep(1);
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ int main(int argc, char **argv) {
return -1;
}

z_owned_closure_sample_t callback = z_closure(data_handler);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(keyexpr), z_move(callback), NULL) < 0) {
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ int main(int argc, char **argv) {
return -1;
}

z_owned_closure_sample_t callback = z_closure(data_handler);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(keyexpr), z_move(callback), NULL) < 0) {
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_sub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ int main(int argc, char **argv) {
}
// Declare Subscriber/resource
z_stats_t *context = z_stats_make();
z_owned_closure_sample_t callback = z_closure(on_sample, drop_stats, (void *)context);
z_owned_closure_sample_t callback;
z_closure(&callback, on_sample, drop_stats, (void *)context);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_loan(s), z_keyexpr(keyexpr), z_move(callback), NULL) < 0) {
printf("Unable to create subscriber.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c99/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ int main(int argc, char **argv) {
if (value != NULL) {
opts.value.payload = _z_bytes_wrap((const uint8_t *)value, strlen(value));
}
z_owned_closure_reply_t callback = z_closure_reply(reply_handler, reply_dropper, NULL);
z_owned_closure_reply_t callback;
z_closure_reply(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_session_loan(&s), ke, "", z_closure_reply_move(&callback), &opts) < 0) {
printf("Unable to send query.\n");
return -1;
Expand Down
6 changes: 4 additions & 2 deletions examples/unix/c99/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ int main(int argc, char **argv) {
print_zid(&self_id, NULL);

printf("Routers IDs:\n");
z_owned_closure_zid_t callback = z_closure_zid(print_zid, NULL, NULL);
z_owned_closure_zid_t callback;
z_closure_zid(&callback, print_zid, NULL, NULL);
z_info_routers_zid(z_session_loan(&s), z_closure_zid_move(&callback));

// `callback` has been `z_move`d just above, so it's safe to reuse the variable,
// we'll just have to make sure we `z_move` it again to avoid mem-leaks.
printf("Peers IDs:\n");
z_owned_closure_zid_t callback2 = z_closure_zid(print_zid, NULL, NULL);
z_owned_closure_zid_t callback2;
z_closure_zid(&callback2, print_zid, NULL, NULL);
z_info_peers_zid(z_session_loan(&s), z_closure_zid_move(&callback2));

// Stop read and lease tasks for zenoh-pico
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ int main(int argc, char** argv) {
}

z_keyexpr_t pong = z_keyexpr_unchecked("test/pong");
z_owned_closure_sample_t respond = z_closure_sample(callback, drop, NULL);
z_owned_closure_sample_t respond;
z_closure_sample(&respond, callback, drop, NULL);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_session_loan(&session), pong, z_closure_sample_move(&respond), NULL) < 0) {
printf("Unable to declare subscriber for key expression.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c99/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ int main(int argc, char** argv) {
}

z_keyexpr_t ping = z_keyexpr_unchecked("test/ping");
z_owned_closure_sample_t respond = z_closure_sample(callback, drop, (void*)z_publisher_move(&pub));
z_owned_closure_sample_t respond;
z_closure_sample(&respond, callback, drop, (void*)z_publisher_move(&pub));
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_session_loan(&session), ping, z_closure_sample_move(&respond), NULL) < 0) {
printf("Unable to declare subscriber for key expression.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c99/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ int main(int argc, char **argv) {
}

// @TODO
// z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
// z_owned_closure_sample_t callback;
// z_closure_sample(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
// @TODO
// z_owned_pull_subscriber_t sub =
Expand Down
4 changes: 3 additions & 1 deletion examples/unix/c99/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ int main(int argc, char **argv) {
return -1;
}

z_owned_closure_query_t callback;
z_closure_query(&callback, query_handler, NULL, NULL);

printf("Creating Queryable on '%s'...\n", keyexpr);
z_owned_closure_query_t callback = z_closure_query(query_handler, NULL, NULL);
z_owned_queryable_t qable = z_declare_queryable(z_session_loan(&s), ke, z_closure_query_move(&callback), NULL);
if (!z_queryable_check(&qable)) {
printf("Unable to create queryable.\n");
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c99/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ int main(int argc, char **argv) {
*context = 0;
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
z_owned_closure_hello_t closure;
z_closure_hello(&closure, callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));
sleep(1);
Expand Down
4 changes: 3 additions & 1 deletion examples/unix/c99/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ int main(int argc, char **argv) {
return -1;
}

z_owned_closure_sample_t callback = z_closure_sample(data_handler, NULL, NULL);
z_owned_closure_sample_t callback;
z_closure_sample(&callback, data_handler, NULL, NULL);

printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
if (z_declare_subscriber(&sub, z_session_loan(&s), z_keyexpr(keyexpr), z_closure_sample_move(&callback), NULL) <
Expand Down
Loading

0 comments on commit dab7394

Please sign in to comment.