summaryrefslogtreecommitdiff
path: root/test/pkev.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/pkev.cpp')
-rw-r--r--test/pkev.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/pkev.cpp b/test/pkev.cpp
index 6258e02..a34b7d5 100644
--- a/test/pkev.cpp
+++ b/test/pkev.cpp
@@ -27,8 +27,8 @@ exit(int code)
struct ev {
pk_ev_mgr_id_T evmgr;
pk_ev_id_T evid;
- int count;
- bool handled;
+ atomic_int count;
+ atomic_bool handled;
};
struct ev ev_one = {};
@@ -58,7 +58,7 @@ typedef struct cb_data {
void stress_cb(void *, void *, void *user_data) {
cb_data *data = reinterpret_cast<cb_data*>(user_data);
data->ev[data->i].handled = true;
- data->ev[data->i].count += 1;
+ data->ev[data->i].count++;
}
void invoke_packged_task(void *, void *, void* ptr) {
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
bool any_false = false;
for (i = 0; i < ev_count; ++i) {
- PK_LOGV_INF("%s: ev# %.2zu: %s, called count: %i\n", __FILE__, i, evs[i].handled ? "true" : "false", evs[i].count);
+ PK_LOGV_INF("%s: ev# %.2zu: %s, called count: %i\n", __FILE__, i, evs[i].handled ? "true" : "false", atomic_load(&evs[i].count));
any_false = any_false || !evs[i].handled;
}
pk_ev_teardown();
@@ -158,19 +158,23 @@ int main(int argc, char *argv[])
}
for (i = 0; i < ev_count; ++i) {
- cb_data *d = new cb_data{};
- d->ev = evs;
+ cb_data *d = new cb_data;
d->i = i;
+ d->ev = &evs[0];
pk_ev_emit(evs[i].evmgr, evs[i].evid, d);
}
bool any_false = false;
uint64_t valid_count = 0;
+ uint64_t partial_valid_count = 0;
for (i = 0; i < ev_count; ++i) {
if (evs[i].handled == true && evs[i].count == 0xFF) valid_count += 1;
+ if (evs[i].handled == true && evs[i].count != 0xFF) {
+ partial_valid_count += 1;
+ }
any_false = any_false || !evs[i].handled;
}
- PK_LOGV_INF("%s: #valid: %lu, called count: %i\n", __FILE__, valid_count, evs[0].count);
+ PK_LOGV_INF("%s: #valid: %lu, #partial_valid: %lu, called count: %i\n", __FILE__, valid_count, partial_valid_count, atomic_load(&evs[0].count));
pk_ev_teardown();
fflush(stdout);
fflush(stderr);