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

Improve Timer Thread Usage #22

Closed
amarqueslee opened this issue Oct 3, 2017 · 1 comment
Closed

Improve Timer Thread Usage #22

amarqueslee opened this issue Oct 3, 2017 · 1 comment

Comments

@amarqueslee
Copy link
Contributor

I have already offered some work to improve our use of timers in this plugin as part of issue #17 . @yuttie has kindly suggested some additional changes which I agree would offer further improvement.

His relevant notes from the referenced issue:

We need to improve the other change for another issue of this plugin.
Thanks to your patch, I found that my original code redundantly starts a new tick thread whenever comfortable_motion#flick() is called, which causes unnatural acceleration.
The second change actually fixes the problem by maintaining only a single persistent tick thread.
However, it also introduces constant CPU usage even when a user doesn't use a vim.
I think we can improve the patch by stopping a tick thread when it is not needed.
This problem should be discussed in another issue.

My initial idea of how to approach this is to retain a single script-wide reference to a tick thread (represented by a timer ID), initially not started. If comfortable_motion#flick() is called when the thread is stopped, we will start the thread (call timer_start). If comfortable_motion#tick() is called and it discovers that scrolling has stopped, it will stop the thread with timer_stop.

@yuttie, does this approach seem appropriate to you?

@yuttie
Copy link
Owner

yuttie commented Feb 22, 2018

I merged #23 , and now I think this issue is resolved.
Closing.

@yuttie yuttie closed this as completed Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants