Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add temporary batching example #789

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/unix/c11/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int main(int argc, char **argv) {
// Publish data
printf("Press CTRL-C to quit...\n");
char buf[256];
zp_batch_start(z_loan(s));
for (int idx = 0; idx < n; ++idx) {
z_sleep_s(1);
sprintf(buf, "[%4d] %s", idx, value);
Expand All @@ -117,7 +118,14 @@ int main(int argc, char **argv) {
z_bytes_copy_from_str(&payload, buf);

z_publisher_put(z_loan(pub), z_move(payload), NULL);

if (idx % 3 == 0) {
printf("FLush data\n");
zp_batch_stop(z_loan(s));
zp_batch_start(z_loan(s));
}
}
zp_batch_stop(z_loan(s));
// Clean up
z_drop(z_move(pub));
z_drop(z_move(s));
Expand Down
Loading