-
Notifications
You must be signed in to change notification settings - Fork 4
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
Pause, resume #14
Comments
Therefore, I have the following task:
|
Command interface
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
True perfect pause not exist
By learn video and document, seems there were no something called "perfect pause at any time".
The implement is use cross thread variable, and tons of if statement to check the variable is changed or not.
Flavor
I personally don't like to see I do one thing a time, but do 150 times to check on a variable.
What is my pause
When I say a pause, I went to gaming or performance matter task.
After I return, I probably don't want to resume from where I left.
Only god know what's in the RAM now. I will continue to prefetch from the start point.
The only case I pause is I don't want to rescan, keep scan result in RAM.
Or I just simply close the program, later start again is also a solution.
Utilize skip variable
So the solution should be done on thread entry, I remember there is a "skip" variable.
That's a chance. The variable has an initial value on creating a thread instance.
I will get the initial value from global, instead always use "false".
Once I set global variable to "true", all new created read thread will inherit "true".
When they are fired, will return immediately and do nothing.
What to do thread runner
The thread pool runner will fire all the thread anyway.
It will change to only check global pause status once before fire any thread.
If thread pool already running, for example 47/1055,
all 1055 thread will fire, and counting on "skip" variable.
The reason mentioned before, I don't like to see every time I do something,
but first I checked a suddenly appeared variable.
Resume
I have
PrefetchInterval
, the one currently is use sleep on loop thread.After send resume command, the rest of interval time should discard and do prefetch now.
So instead of sleep on the loop thread, the sleep will change to a new thread,
and loop thread will try to join the sleep thread.
In this case, when it comes to resume, I terminate the sleep thread,
prefetch will start immediately.
The text was updated successfully, but these errors were encountered: