Techniques for switching threads within routines
First Claim
1. A method comprising:
- executing an initial portion of a routine on an initial thread;
processing a first return statement that is a yield statement, the processing of the first 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 a subsequent thread identifier included in the return statement, the return statement provided in response to the processing of the initial portion; and
performing a subsequent execution of the routine on the subsequent thread via the first return statement, the subsequent execution executing a subsequent portion of the routine from the end point of the initial portion.
2 Assignments
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.
23 Citations
18 Claims
-
1. A method comprising:
-
executing an initial portion of a routine on an initial thread; processing a first return statement that is a yield statement, the processing of the first 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 a subsequent thread identifier included in the return statement, the return statement provided in response to the processing of the initial portion; and performing a subsequent execution of the routine on the subsequent thread via the first return statement, the subsequent execution executing a subsequent portion of the routine from the end point of the initial portion. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A computer-readable memory storing instructions executable by a computing device to cause the computing device to perform operations comprising:
-
processing an initial portion of a routine on a first thread; exiting the routine at an end point of the initial portion, the exiting caused by a processing of a first return statement that is a yield statement; identifying a subsequent thread different than the first thread via a subsequent thread identifier included in the return statement, the return statement provided in response to the processing of the initial portion; and performing a subsequent processing of the routine from the end point on the subsequent thread via the first return statement. - View Dependent Claims (10, 11, 12, 13)
-
-
14. A system, comprising at least one processor coupled to at least one computer-readable storage medium storing instructions executable by the at least one processor to implement:
-
executing code corresponding to an initial portion of a routine on a first thread; exiting the routine temporarily in response to a processing of a first return statement that is a yield statement; and switching from an execution of the initial portion of the routine on the first thread to a subsequent execution of a subsequent portion of the routine on a second thread via the first return statement, the first thread different than the second thread, the switching comprising identifying the subsequent thread via a parameter included in the return statement, the return statement provided in response to the execution of the initial portion. - View Dependent Claims (15, 16, 17, 18)
-
Specification