X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Ftest%2Fmsgr%2Ftest_async_driver.cc;h=e68e57b6ba83e428883883da10cca4b9d8e1dbbc;hb=31f18b776d001752a193a7cec8bb49033c1a904c;hp=a93cffa0f4e2978ee26943ffd4a2ba054e29f88a;hpb=40152f1e46a80b3405e5558a442ee632198dfd24;p=ceph.git diff --git a/ceph/src/test/msgr/test_async_driver.cc b/ceph/src/test/msgr/test_async_driver.cc index a93cffa0f..e68e57b6b 100644 --- a/ceph/src/test/msgr/test_async_driver.cc +++ b/ceph/src/test/msgr/test_async_driver.cc @@ -24,13 +24,14 @@ #include #include #include "include/Context.h" -#include "include/atomic.h" #include "common/Mutex.h" #include "common/Cond.h" #include "global/global_init.h" #include "common/ceph_argparse.h" #include "msg/async/Event.h" +#include + // We use epoll, kqueue, evport, select in descending order by performance. #if defined(__linux__) #define HAVE_EPOLL 1 @@ -293,15 +294,15 @@ class Worker : public Thread { }; class CountEvent: public EventCallback { - atomic_t *count; + std::atomic *count; Mutex *lock; Cond *cond; public: - CountEvent(atomic_t *atomic, Mutex *l, Cond *c): count(atomic), lock(l), cond(c) {} + CountEvent(std::atomic *atomic, Mutex *l, Cond *c): count(atomic), lock(l), cond(c) {} void do_request(int id) override { lock->Lock(); - count->dec(); + (*count)--; cond->Signal(); lock->Unlock(); } @@ -309,18 +310,18 @@ class CountEvent: public EventCallback { TEST(EventCenterTest, DispatchTest) { Worker worker1(g_ceph_context, 1), worker2(g_ceph_context, 2); - atomic_t count(0); + std::atomic count = { 0 }; Mutex lock("DispatchTest::lock"); Cond cond; worker1.create("worker_1"); worker2.create("worker_2"); for (int i = 0; i < 10000; ++i) { - count.inc(); + count++; worker1.center.dispatch_event_external(EventCallbackRef(new CountEvent(&count, &lock, &cond))); - count.inc(); + count++; worker2.center.dispatch_event_external(EventCallbackRef(new CountEvent(&count, &lock, &cond))); Mutex::Locker l(lock); - while (count.read()) + while (count) cond.Wait(lock); } worker1.stop();