DreamPearl commented on code in PR #379: URL: https://github.com/apache/qpid-proton/pull/379#discussion_r1005605843
########## cpp/src/container_test.cpp: ########## @@ -574,6 +575,116 @@ void test_container_mt_close_race() { } } +class schedule_cancel : public proton::messaging_handler { + proton::listener listener; + test_listen_handler listen_handler; + long long w1_handle; + long long w2_handle; + long long w3_handle; + long long w4_handle; + long long w5_handle; + + void change_w1_state(proton::container* c) { + w1_state = 1; + } + + void change_w2_state(proton::container* c) { + w2_state = 1; + } + + void change_w3_state(proton::container* c) { + w3_state = 1; + } + + void change_w4_state(proton::container* c) { + w4_state = 1; + } + + void change_w5_state(proton::container* c) { + w5_state = 1; + } + + void on_container_start(proton::container& c) override { + ASSERT(w1_state==0); + ASSERT(w2_state==0); + ASSERT(w3_state==0); + ASSERT(w4_state==0); + ASSERT(w5_state==0); + + listener = c.listen("//:0", listen_handler); + + // We will cancel this scheduled task before its execution. + w1_handle = c.schedule(proton::duration(250), proton::make_work(&schedule_cancel::change_w1_state, this, &c)); + + // We will cancel this scheduled task before its execution and will try to cancel it again. + w2_handle = c.schedule(proton::duration(260), proton::make_work(&schedule_cancel::change_w2_state, this, &c)); + + // We will not cancel this scheduled task. + w3_handle = c.schedule(proton::duration(35), proton::make_work(&schedule_cancel::change_w3_state, this, &c)); + + // We will try to cancel this task before its execution from different thread i.e connection thread. + w4_handle = c.schedule(proton::duration(270), proton::make_work(&schedule_cancel::change_w4_state, this, &c)); + + // We will try to cancel this task after its execution from different thread i.e. connection thread. + w5_handle = c.schedule(proton::duration(0), proton::make_work(&schedule_cancel::change_w5_state, this, &c)); Review Comment: @astitcher Scheduling the task to execute after 0 ms. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org