oxen-mq/tests
Jason Rhinelander cdc6a9709c Add thread-safe timerid assignment version of add_timer()
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).
2021-05-25 17:29:25 -03:00
..
Catch2@b3b07215d1 Add initial test suite with some batch job tests 2020-02-06 18:10:26 -04:00
CMakeLists.txt Add timer cancellation & timer tests 2021-05-20 22:05:58 -03:00
common.h Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
main.cpp Add initial test suite with some batch job tests 2020-02-06 18:10:26 -04:00
test_address.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_batch.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_bt.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_commands.cpp Add support for std::optional<T> send arguments 2021-04-20 13:54:42 -03:00
test_connect.cpp Rename PUBKEY_BASED_ROUTING_ID to EPHEMERAL_ROUTING_ID 2021-04-15 15:42:04 -03:00
test_encoding.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_failures.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_inject.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_requests.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_tagged_threads.cpp Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
test_timer.cpp Add thread-safe timerid assignment version of add_timer() 2021-05-25 17:29:25 -03:00