]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
test/multi_stress_watch: use condition_variable for level triggering 36820/head
authorKefu Chai <kchai@redhat.com>
Wed, 26 Aug 2020 09:56:59 +0000 (17:56 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 26 Aug 2020 11:17:54 +0000 (19:17 +0800)
commit6b36eb949c36fbcc0df99c94992bbd8e28b146d7
tree23c452bdff26b454fd3b121251f424b01c608888
parentfb44c2f5009f8e2e18663251149c3bf6b06256a9
test/multi_stress_watch: use condition_variable for level triggering

* use mutex+condition_variable instead of POSIX semaphore, for
  couple reasons:
  - for using POSIX semaphore, we should set the initial value:
    before this change, sem_init() is not called, so the initial
    value of the semaphore is not set.
  - use condition_variable::wait_for() instead of TestAlarm. simpler
    this way. and avoid hiding the magic numbers -- if we choose to
    live with them, make them more visible.
  - use RAII to avoid sem_init() and sem_destroy()
  - use a member variable for being level triggered. as notify()
    could be called before wait() is called.
* define 10000 using a constant variable: NR_ITERATIONS
* remove unused `#include <sstream>` and using declaration.
* use cout for printing informative messages

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/multi_stress_watch.cc