Skip to content

Commit

Permalink
feat: switch the rest to zp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jan 9, 2024
1 parent d98dfab commit bfecbb0
Show file tree
Hide file tree
Showing 107 changed files with 925 additions and 925 deletions.
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void app_main(void) {
}

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
printf("Sending Query '%s'...\n", KEYEXPR);
z_get_options_t opts = z_get_options_default();
if (strcmp(VALUE, "") != 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void app_main(void) {

char *buf = (char *)pvPortMalloc(256);
for (int idx = 0; 1; ++idx) {
z_sleep_s(1);
zp_sleep_s(1);
snprintf(buf, 256, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);

Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ void app_main(void) {
}

char *buf = (char *)pvPortMalloc(256);
z_clock_t now = z_clock_now();
zp_clock_t now = zp_clock_now();
for (int idx = 0; 1;) {
if (z_clock_elapsed_ms(&now) > 1000) {
if (zp_clock_elapsed_ms(&now) > 1000) {
snprintf(buf, 256, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);
z_publisher_put(z_loan(pub), (const uint8_t *)buf, strlen(buf), NULL);
++idx;

now = z_clock_now();
now = zp_clock_now();
}

zp_read(z_loan(s), NULL);
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void app_main(void) {
}

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
printf("Pulling data from '%s'...\n", KEYEXPR);
z_subscriber_pull(z_loan(sub));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void app_main(void) {
}

while (1) {
z_sleep_s(1);
zp_sleep_s(1);
}

z_undeclare_keyexpr(z_loan(s), z_move(ke));
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void app_main(void) {
}

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
}

z_undeclare_queryable(z_move(qable));
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void app_main(void) {
}

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
}

z_undeclare_subscriber(z_move(sub));
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char **argv) {
zp_start_lease_task(z_session_loan(&s), NULL);

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
printf("Sending Query '%s'...\n", KEYEXPR);
z_get_options_t opts = z_get_options_default();
if (strcmp(VALUE, "") != 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {

char buf[256];
for (int idx = 0; 1; ++idx) {
z_sleep_s(1);
zp_sleep_s(1);
sprintf(buf, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);
z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)buf, strlen(buf), NULL);
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv) {
printf("OK!\n");

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
printf("Pulling data from '%s'...\n", KEYEXPR);
z_subscriber_pull(z_pull_subscriber_loan(&sub));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char **argv) {
printf("Zenoh setup finished!\n");

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
}

printf("Closing Zenoh Session...");
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv) {
printf("OK!\n");

while (1) {
z_sleep_s(5);
zp_sleep_s(5);
}

printf("Closing Zenoh Session...");
Expand Down
32 changes: 16 additions & 16 deletions examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ static zp_mutex_t mutex;
void callback(const z_sample_t* sample, void* context) {
(void)sample;
(void)context;
z_condvar_signal(&cond);
zp_condvar_signal(&cond);
}
void drop(void* context) {
(void)context;
z_condvar_free(&cond);
zp_condvar_free(&cond);
}

struct args_t {
Expand All @@ -61,8 +61,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
z_mutex_init(&mutex);
z_condvar_init(&cond);
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_owned_config_t config = z_config_default();
z_owned_session_t session = z_open(z_move(config));
if (!z_check(session)) {
Expand Down Expand Up @@ -91,34 +91,34 @@ int main(int argc, char** argv) {
return -1;
}

uint8_t* data = z_malloc(args.size);
uint8_t* data = zp_malloc(args.size);
for (unsigned int i = 0; i < args.size; i++) {
data[i] = i % 10;
}
z_mutex_lock(&mutex);
zp_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
z_clock_t warmup_start = z_clock_now();
zp_clock_t warmup_start = zp_clock_now();
unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_publisher_put(z_loan(pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
elapsed_us = z_clock_elapsed_us(&warmup_start);
zp_condvar_wait(&cond, &mutex);
elapsed_us = zp_clock_elapsed_us(&warmup_start);
}
}
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
unsigned long* results = zp_malloc(sizeof(unsigned long) * args.number_of_pings);
for (unsigned int i = 0; i < args.number_of_pings; i++) {
z_clock_t measure_start = z_clock_now();
zp_clock_t measure_start = zp_clock_now();
z_publisher_put(z_loan(pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
results[i] = z_clock_elapsed_us(&measure_start);
zp_condvar_wait(&cond, &mutex);
results[i] = zp_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
}
z_mutex_unlock(&mutex);
z_free(results);
z_free(data);
zp_mutex_unlock(&mutex);
zp_free(results);
zp_free(data);
z_drop(z_move(pub));
z_drop(z_move(sub));

Expand Down
12 changes: 6 additions & 6 deletions examples/unix/c11/z_sub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
typedef struct {
volatile unsigned long count;
volatile unsigned long finished_rounds;
z_clock_t start;
z_clock_t first_start;
zp_clock_t start;
zp_clock_t first_start;
} z_stats_t;

#if Z_FEATURE_SUBSCRIPTION == 1
Expand All @@ -44,14 +44,14 @@ void on_sample(const z_sample_t *sample, void *context) {
stats->count++;
// Start set measurement
if (stats->count == 1) {
stats->start = z_clock_now();
stats->start = zp_clock_now();
if (stats->first_start.tv_nsec == 0) {
stats->first_start = stats->start;
}
} else if (stats->count >= PACKET_NB) {
// Stop set measurement
stats->finished_rounds++;
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->start);
unsigned long elapsed_ms = zp_clock_elapsed_ms(&stats->start);
printf("Received %d msg in %lu ms (%.1f msg/s)\n", PACKET_NB, elapsed_ms,
(double)(PACKET_NB * 1000) / (double)elapsed_ms);
stats->count = 0;
Expand All @@ -60,7 +60,7 @@ void on_sample(const z_sample_t *sample, void *context) {

void drop_stats(void *context) {
z_stats_t *stats = (z_stats_t *)context;
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->first_start);
unsigned long elapsed_ms = zp_clock_elapsed_ms(&stats->first_start);
const unsigned long sent_messages = PACKET_NB * stats->finished_rounds + stats->count;
printf("Stats after unsubscribing: received %ld messages over %lu miliseconds (%.1f msg/s)\n", sent_messages,
elapsed_ms, (double)(sent_messages * 1000) / (double)elapsed_ms);
Expand Down Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv) {
}
// Wait for everything to settle
printf("End of test\n");
z_sleep_s(1);
zp_sleep_s(1);
// Clean up
z_undeclare_subscriber(z_move(sub));
zp_stop_read_task(z_loan(s));
Expand Down
32 changes: 16 additions & 16 deletions examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ static zp_mutex_t mutex;
void callback(const z_sample_t* sample, void* context) {
(void)sample;
(void)context;
z_condvar_signal(&cond);
zp_condvar_signal(&cond);
}
void drop(void* context) {
(void)context;
z_condvar_free(&cond);
zp_condvar_free(&cond);
}

struct args_t {
Expand All @@ -62,8 +62,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
z_mutex_init(&mutex);
z_condvar_init(&cond);
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_owned_config_t config = z_config_default();
z_owned_session_t session = z_open(z_config_move(&config));
if (!z_session_check(&session)) {
Expand Down Expand Up @@ -93,34 +93,34 @@ int main(int argc, char** argv) {
return -1;
}

uint8_t* data = z_malloc(args.size);
uint8_t* data = zp_malloc(args.size);
for (unsigned int i = 0; i < args.size; i++) {
data[i] = i % 10;
}
z_mutex_lock(&mutex);
zp_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
z_clock_t warmup_start = z_clock_now();
zp_clock_t warmup_start = zp_clock_now();
unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
elapsed_us = z_clock_elapsed_us(&warmup_start);
zp_condvar_wait(&cond, &mutex);
elapsed_us = zp_clock_elapsed_us(&warmup_start);
}
}
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
unsigned long* results = zp_malloc(sizeof(unsigned long) * args.number_of_pings);
for (unsigned int i = 0; i < args.number_of_pings; i++) {
z_clock_t measure_start = z_clock_now();
zp_clock_t measure_start = zp_clock_now();
z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
results[i] = z_clock_elapsed_us(&measure_start);
zp_condvar_wait(&cond, &mutex);
results[i] = zp_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
}
z_mutex_unlock(&mutex);
z_free(results);
z_free(data);
zp_mutex_unlock(&mutex);
zp_free(results);
zp_free(data);
z_undeclare_subscriber(z_subscriber_move(&sub));
z_undeclare_publisher(z_publisher_move(&pub));

Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c99/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ int main(int argc, char **argv) {
}

char *buf = (char *)malloc(256);
z_clock_t now = z_clock_now();
zp_clock_t now = zp_clock_now();
for (int idx = 0; 1;) {
if (z_clock_elapsed_ms(&now) > 1000) {
if (zp_clock_elapsed_ms(&now) > 1000) {
snprintf(buf, 256, "[%4d] %s", idx, value);
printf("Putting Data ('%s': '%s')...\n", keyexpr, buf);
z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)buf, strlen(buf), NULL);
++idx;

now = z_clock_now();
now = zp_clock_now();
}

zp_read(z_session_loan(&s), NULL);
Expand Down
32 changes: 16 additions & 16 deletions examples/windows/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ static zp_mutex_t mutex;
void callback(const z_sample_t* sample, void* context) {
(void)sample;
(void)context;
z_condvar_signal(&cond);
zp_condvar_signal(&cond);
}
void drop(void* context) {
(void)context;
z_condvar_free(&cond);
zp_condvar_free(&cond);
}

struct args_t {
Expand All @@ -61,8 +61,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
z_mutex_init(&mutex);
z_condvar_init(&cond);
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_owned_config_t config = z_config_default();
z_owned_session_t session = z_open(z_move(config));
if (!z_check(session)) {
Expand Down Expand Up @@ -90,34 +90,34 @@ int main(int argc, char** argv) {
return -1;
}

uint8_t* data = z_malloc(args.size);
uint8_t* data = zp_malloc(args.size);
for (unsigned int i = 0; i < args.size; i++) {
data[i] = i % 10;
}
z_mutex_lock(&mutex);
zp_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
z_clock_t warmup_start = z_clock_now();
zp_clock_t warmup_start = zp_clock_now();
unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_publisher_put(z_loan(pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
elapsed_us = z_clock_elapsed_us(&warmup_start);
zp_condvar_wait(&cond, &mutex);
elapsed_us = zp_clock_elapsed_us(&warmup_start);
}
}
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
unsigned long* results = zp_malloc(sizeof(unsigned long) * args.number_of_pings);
for (unsigned int i = 0; i < args.number_of_pings; i++) {
z_clock_t measure_start = z_clock_now();
zp_clock_t measure_start = zp_clock_now();
z_publisher_put(z_loan(pub), data, args.size, NULL);
z_condvar_wait(&cond, &mutex);
results[i] = z_clock_elapsed_us(&measure_start);
zp_condvar_wait(&cond, &mutex);
results[i] = zp_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luus, lat=%luus\n", args.size, i, results[i], results[i] / 2);
}
z_mutex_unlock(&mutex);
z_free(results);
z_free(data);
zp_mutex_unlock(&mutex);
zp_free(results);
zp_free(data);
z_drop(z_move(pub));
z_drop(z_move(sub));

Expand Down
Loading

0 comments on commit bfecbb0

Please sign in to comment.