mirror of https://github.com/oxen-io/oxen-mq.git
cdc6a9709c
I realized after merging the previous PR that it is difficult to correctly pass ownership into a timer, because something like: TimerID x = omq.add_timer([&] { omq.cancel_timer(x); }, 5ms); doesn't work when the timer job needs to outlive the caller. My next approach was: auto x = std::make_shared<TimerID>(); *x = omq.add_timer([&omq, x] { omq.cancel_timer(*x); }, 5ms); but this has two problems: first, TimerID wasn't default constructible, and second, there is no guarantee that the assignment to *x happens before (and is visible to) the access for the cancellation. This commit fixes both issues: TimerID is now default constructible, and an overload is added that takes the lvalue reference to the TimerID to set rather than returning it (and guarantees that it will be set before the timer is created). |
||
---|---|---|
.. | ||
Catch2@b3b07215d1 | ||
CMakeLists.txt | ||
common.h | ||
main.cpp | ||
test_address.cpp | ||
test_batch.cpp | ||
test_bt.cpp | ||
test_commands.cpp | ||
test_connect.cpp | ||
test_encoding.cpp | ||
test_failures.cpp | ||
test_inject.cpp | ||
test_requests.cpp | ||
test_tagged_threads.cpp | ||
test_timer.cpp |