Techniques for switching threads within routes
First Claim
1. A method comprising:
- executing an initial portion of a routine on an initial thread;
processing a return statement that is a yield statement, the processing of the return statement causing the routine to temporarily exit the routine at an end point of the initial portion;
identifying a subsequent thread different than the initial thread via the return statement, the return statement provided in response to the executing of the initial portion; and
performing a subsequent execution of the routine via the return statement, the subsequent execution executing a subsequent portion of the routine from the end point of the initial portion.
1 Assignment
0 Petitions
Accused Products
Abstract
Various technologies and techniques are disclosed for switching threads within routines. A controller routine receives a request from an originating routine to execute a coroutine, and executes the coroutine on an initial thread. The controller routine receives a response back from the coroutine when the coroutine exits based upon a return statement. Upon return, the coroutine indicates a subsequent thread that the coroutine should be executed on when the coroutine is executed a subsequent time. The controller routine executes the coroutine the subsequent time on the subsequent thread. The coroutine picks up execution at a line of code following the return statement. Multiple return statements can be included in the coroutine, and the threads can be switched multiple times using this same approach. Graphical user interface logic and worker thread logic can be co-mingled into a single routine.
17 Citations
3 Claims
-
1. A method comprising:
-
executing an initial portion of a routine on an initial thread; processing a return statement that is a yield statement, the processing of the return statement causing the routine to temporarily exit the routine at an end point of the initial portion; identifying a subsequent thread different than the initial thread via the return statement, the return statement provided in response to the executing of the initial portion; and performing a subsequent execution of the routine via the return statement, the subsequent execution executing a subsequent portion of the routine from the end point of the initial portion.
-
-
2. A system comprising:
-
memory to store instructions; a processor to execute the instructions to; execute an initial portion of a routine on an initial thread; process a return statement that is a yield statement to cause the routine to temporarily exit the routine at an end point of the initial portion; identify a subsequent thread different than the initial thread via the return statement, the return statement provided in response to the execution of the initial portion; and perform a subsequent execution of the routine via the return statement, the subsequent execution to execute a subsequent portion of the routine from the end point of the initial portion.
-
-
3. A computer readable storage device storing computer-executable instructions to control a computer system to:
-
execute an initial portion of a routine on an initial thread; process a return statement that is a yield statement to cause the routine to temporarily exit the routine at an end point of the initial portion; identify a subsequent thread different than the initial thread via the return statement, the return statement provided in response to the execution of the initial portion; and perform a subsequent execution of the routine via the return statement, the subsequent execution to execute a subsequent portion of the routine from the end point of the initial portion.
-
Specification