Pausing a thread under program control
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
5 posts
• Page 1 of 1
Pausing a thread under program control
I would like, in a multi-threaded system, to be able to "Pause" a thread under direct program control from another thread.
That is to change a selected thread's "Flag" from "Normal" to "Paused" (and back again).
Has anybody any ideas about how to achieve this?
Is there say, a "System Operator" (such as [Paused] ) one can call perhaps?. (As in the "Threads Tool Pop-Up Menu" that toggles a thread between being Paused and Normal.)
Anybody got any suggestions?
Thanks
That is to change a selected thread's "Flag" from "Normal" to "Paused" (and back again).
Has anybody any ideas about how to achieve this?
Is there say, a "System Operator" (such as [Paused] ) one can call perhaps?. (As in the "Threads Tool Pop-Up Menu" that toggles a thread between being Paused and Normal.)
Anybody got any suggestions?
Thanks
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Pausing a thread under program control
Have you tried using tokens? I have several instances where a child thread waits on a token, upon receiving it performs a specific action & then returns to wait on another instance of that token.
Works very well
Works very well
- crishog
- Posts: 61
- Joined: Mon Jan 25, 2010 9:52 am
Re: Pausing a thread under program control
Thanks for the suggestion.
I have used tokens in the past in a loop, testing for the existence of the token each time around the loop, but this thread does not run in/as a loop.
So I would have to test for the token in multiple locations, spread throughout the code of the thread.
I will be using tokens to control the information passing between threads.
What I want to do is SUSPEND and then RESUME processing of ONE of the threads.
I have used tokens in the past in a loop, testing for the existence of the token each time around the loop, but this thread does not run in/as a loop.
So I would have to test for the token in multiple locations, spread throughout the code of the thread.
I will be using tokens to control the information passing between threads.
What I want to do is SUSPEND and then RESUME processing of ONE of the threads.
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Pausing a thread under program control
If you use a token with a negative value it can be repeatedly fetched without removing it from the pool. Therefore a few judiciously placed TGETs (using the positive value)in your sub-thread should be enough. As long at the value is in the pool the child thread will run.
Just TGET the negative value in the main thread - the child will pause when it gets to any of the TGETs of the positive value & you restart it by the main thread TPUTing the negative value back into the pool.
Just TGET the negative value in the main thread - the child will pause when it gets to any of the TGETs of the positive value & you restart it by the main thread TPUTing the negative value back into the pool.
- crishog
- Posts: 61
- Joined: Mon Jan 25, 2010 9:52 am
Re: Pausing a thread under program control
Thanks again.
You say "Therefore a few judiciously placed TGETs"
The problem is that I will need a TGET in every process taking significant time in my thread, a lot, not a few. (at least a dozen, maybe more).
Tokens are very usefull and powerfull at communicating between threads.
I need something more like an OnEvent trap : onTokenRecieved
I suppose I could check for a token in a loop, and on recipe, signal a user defined error which could be trapped and acted on by the thread.
Thanks anyway
You say "Therefore a few judiciously placed TGETs"
The problem is that I will need a TGET in every process taking significant time in my thread, a lot, not a few. (at least a dozen, maybe more).
Tokens are very usefull and powerfull at communicating between threads.
I need something more like an OnEvent trap : onTokenRecieved
I suppose I could check for a token in a loop, and on recipe, signal a user defined error which could be trapped and acted on by the thread.
Thanks anyway
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group