[ https://issues.apache.org/jira/browse/THRIFT-4292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16158735#comment-16158735 ]
ASF GitHub Bot commented on THRIFT-4292: ---------------------------------------- Github user Typz commented on a diff in the pull request: https://github.com/apache/thrift/pull/1337#discussion_r137810110 --- Diff: lib/cpp/test/concurrency/TimerManagerTests.h --- @@ -126,6 +126,38 @@ class TimerManagerTests { return true; } + /** + * This test creates two tasks, removes the first one then waits for the second one. It then + * verifies that the timer manager properly clean up itself and the remaining orphaned timeout + * task when the manager goes out of scope and its destructor is called. + */ + bool test01(int64_t timeout = 1000LL) { + TimerManager timerManager; + timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.start(); + assert(timerManager.state() == TimerManager::STARTED); + + Synchronized s(_monitor); + + // Setup the two tasks + shared_ptr<TimerManagerTests::Task> taskToRemove + = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, timeout / 2)); + timerManager.add(taskToRemove, taskToRemove->_timeout); + + shared_ptr<TimerManagerTests::Task> task + = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, timeout)); + timerManager.add(task, task->_timeout); + + // Remove one task and wait until the other has completed + timerManager.remove(taskToRemove); + _monitor.wait(timeout * 2); + + assert(!taskToRemove->_done); + assert(task->_done); + + return true; + } + --- End diff -- done > TimerManager::remove() is not implemented > ----------------------------------------- > > Key: THRIFT-4292 > URL: https://issues.apache.org/jira/browse/THRIFT-4292 > Project: Thrift > Issue Type: Bug > Components: C++ - Library > Reporter: Francois Ferrand > > The function is currently not implemented. > This is not critical for Thrift, since it is not used there, but prevents > using it in thrift-based code. -- This message was sent by Atlassian JIRA (v6.4.14#64029)