AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Thread, ContinueInterrupted

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
infogulch



Joined: 27 Mar 2008
Posts: 184

PostPosted: Tue May 27, 2008 9:11 pm    Post subject: Thread, ContinueInterrupted Reply with quote

Wait, ms EDIT: this would pretty much be useless. /EDIT
Could allow other threads to run instead of stopping the entire script like sleep does. (other threads could be started by: hotkey, gui, menu, timer)
Like Keywait: Maunal Wrote:While the command is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.


Thread, ContinueInterrupted [, False] (needs shorter name Razz )
A setting (like DetectHiddenWindows) that, if the current thread interrupted another, whenever it encounters a Wait or KeyWait, it goes back to the interrupted thread and continues execution until the *Wait is over in which case it interrupts agian to finish. (Of course, it would not apply to GoSub or a function call as they aren't new threads, but a branch of the current thread.)


Ok, that may be a little confusing, so here's a conceptual example:

Quote:
ThreadA is running
...
User pressed a hotkey while ThreadA is running, so ThreadB starts
...
ThreadB defines the option "Thread, ContinueInterrupted"
...
ThreadB encounters a "Wait 2000" so ThreadB stops
Since the "Thread, ContinueInterrupted" option has been set on, ThreadA resumes.
...
ThreadB's wait is over, so ThreadA is interrupted agian and ThreadB finishes.
ThreadA continues at the second interruption and finishes.



Both of these would speed up work of the script, since they don't ever completely stop the script, and when an interrupting thread stops, the others beneath it would continue, thus allowing the most work to be done in the allotted cpu time.

Needs a better name, it's too long.
_________________
A great Beginner's Tutorial


Last edited by infogulch on Sun Jun 01, 2008 3:07 am; edited 1 time in total
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2737
Location: Australia, Qld

PostPosted: Fri May 30, 2008 11:21 pm    Post subject: Reply with quote

When a new thread starts, the current thread's settings are saved into a structure allocated on the stack. This means that the current thread cannot resume until the new thread finishes.

I think that while the feature you are suggesting would be an improvement, it would require fairly major changes to the way threading works. True multi-threading support would likely require similar (and more) restructuring, but would be more powerful.
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 184

PostPosted: Sat May 31, 2008 12:30 am    Post subject: Reply with quote

I see. That's too bad. EDIT: Uh, nvm. /EIDT What about a plain "Wait" instead of "Sleep"? That would allow timers, hotkeys etc to run while it's waiting, instead of completely stopping the whole script.

Do you think ContinueInterrupted a good enough idea to implement when multi-threading is added? Since it would require similar restructuring..
Smile
_________________
A great Beginner's Tutorial


Last edited by infogulch on Sun Jun 01, 2008 3:13 am; edited 1 time in total
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2737
Location: Australia, Qld

PostPosted: Sat May 31, 2008 5:14 am    Post subject: Reply with quote

infogulch wrote:
That would allow timers, hotkeys etc to run while it's waiting, instead of completely stopping the whole script.
the manual wrote:
While sleeping, new threads can be launched via hotkey, custom menu item, or timer.

infogulch wrote:
Do you think ContinueInterrupted a good enough idea to implement when multi-threading is added?
What would be its benefit over the current behaviour, or actual simultaneous execution?
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 184

PostPosted: Sun Jun 01, 2008 4:50 am    Post subject: Reply with quote

Sleep:
Omg, that completely missed me, sry. I guess "wait" wouldn't do anything but add another command. (but you're always looking for more complication right? Razz Wink )

Thread, ContinueInterrupted:
Currently, if an interrupting (hotkey/timer) thread stops (sleep/keywait), the thread it interrupted is stopped too.
This command would allow that thread that was originally running to be restarted and execution resumed in it. (until the stopped thread is done waiting)

Why? it keeps the script moving and working, so if there's are lines to be executed in a different thread, they aren't hindered, using more of the script's allotted cpu time.

I'm thinking maybe the thread's priority could affect wether it goes back to the interrupted thread, on a per thread basis. E.g. if an interrupting thread with a higher priority than the one it interrupted encounters a sleep, it doesn't go back to the previous thread...
Just throwing around ideas.

Thanks for being patient with me. Confused Very Happy
_________________
A great Beginner's Tutorial
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group