aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bench_network.cpp2
-rw-r--r--test/test_queue.cpp23
2 files changed, 18 insertions, 7 deletions
diff --git a/test/bench_network.cpp b/test/bench_network.cpp
index 1185c0d..b1f1a0f 100644
--- a/test/bench_network.cpp
+++ b/test/bench_network.cpp
@@ -97,7 +97,7 @@ struct MyNet: public MsgNetworkByteOp {
struct Conn: public MsgNetworkByteOp::Conn {
MyNet *get_net() { return static_cast<MyNet *>(get_pool()); }
- salticidae::RcObj<Conn> self() {
+ salticidae::ArcObj<Conn> self() {
return salticidae::static_pointer_cast<Conn>(
MsgNetworkByteOp::Conn::self());
}
diff --git a/test/test_queue.cpp b/test/test_queue.cpp
index bed88c4..a2444d3 100644
--- a/test/test_queue.cpp
+++ b/test/test_queue.cpp
@@ -4,13 +4,22 @@
#include "salticidae/event.h"
-void test_mpsc(int nproducers = 16, int nops = 100000) {
+void test_mpsc(int nproducers = 16, int nops = 100000, size_t burst_size = 128) {
size_t total = nproducers * nops;
salticidae::EventContext ec;
std::atomic<size_t> collected(0);
- salticidae::MPSCQueueEventDriven<int> q(ec, [&collected](int x) {
- printf("%d\n", x);
- collected.fetch_add(1);
+ using queue_t = salticidae::MPSCQueueEventDriven<int>;
+ queue_t q;
+ q.reg_handler(ec, [&collected, burst_size](queue_t &q) {
+ size_t cnt = burst_size;
+ int x;
+ while (q.try_dequeue(x))
+ {
+ printf("%d\n", x);
+ collected.fetch_add(1);
+ if (!--cnt) return true;
+ }
+ return false;
});
std::vector<std::thread> producers;
std::thread consumer([&collected, total, &ec]() {
@@ -39,6 +48,7 @@ void test_mpsc(int nproducers = 16, int nops = 100000) {
fprintf(stderr, "consumers terminate\n");
}
+/*
void test_mpmc(int nproducers = 16, int nconsumers = 4, int nops = 100000) {
size_t total = nproducers * nops;
salticidae::MPMCQueueEventDriven<int> q;
@@ -84,9 +94,10 @@ void test_mpmc(int nproducers = 16, int nconsumers = 4, int nops = 100000) {
for (auto &t: consumers) t.join();
fprintf(stderr, "consumers terminate\n");
}
+*/
int main() {
- //test_mpsc();
- test_mpmc();
+ test_mpsc();
+ //test_mpmc();
return 0;
}