Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-4327: add API to efficiently remove a single timer #1353

Closed
wants to merge 1 commit into from

Conversation

francoisferrand
Copy link
Contributor

No description provided.

@@ -69,28 +72,33 @@ class TimerManager {
*
* @param task The task to execute
* @param timeout Time in milliseconds to delay before executing task
* @return Handle of the timer, which can be used to remose the timer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remose == remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

timerManager.add(task, task->_timeout);

// Remove one task and wait until the other has completed
timerManager.remove(timer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend calling remove a second time and validating expected behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @throws UncancellableTaskException Specified task is already being
* executed or has completed execution.
*/
virtual void remove(Timer timer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was removal of a task insufficient in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old function removes all timers executing this task, and does this inefficiently by traversing the whole list.
This new function removes a single timer in constant time [O(1)] which may be significant for large system with many timers.
This does not impact the behavior of Thrift itself, since it does not rely on timer removal.

@asfgit asfgit closed this in 6960370 Sep 21, 2017
gadLinux pushed a commit to gadLinux/thrift that referenced this pull request Sep 22, 2017
jeking3 pushed a commit to jeking3/thrift that referenced this pull request Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants