Coroutine Thread Switching via Controller Routine
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Developers face challenges in writing complex source code to manage multiple threads in software applications, often leading to inefficient or incorrect usage of threads, resulting in user interface blocks and poor user experience.
Innovation Solution
The implementation of a controller routine that manages the execution of coroutines across different threads, allowing for seamless switching between threads within a single routine, enabling the co-mingling of graphical user interface logic and worker thread logic, and using return statements to specify subsequent threads for execution.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If multiple threads are used to handle user input and worker tasks simultaneously, then application productivity and responsiveness are improved, but source code complexity and difficulty of managing threads increase
Solution Approach 1:
The patent segments the thread management complexity by introducing a dedicated controller routine that separates thread scheduling logic from the main application code. The controller routine manages coroutine execution across multiple threads, allowing worker tasks to be distributed without increasing overall source code complexity.
Solution Approach 2:
The controller routine acts as an intermediary between the coroutine logic and the thread execution system. It receives coroutines from the originating routine, executes them on appropriate threads, and handles thread switching through return statements, thereby mediating the complexity of multi-threaded coordination.
2Ease of operation
If threads are used for background processing, then user interface blocking is reduced and user experience is improved, but correctness and reliability of thread management decrease
Solution Approach 1:
The controller routine implements feedback mechanisms through return statements that allow coroutines to signal completion or need for thread switching. The controller receives responses from coroutines and adjusts thread assignment accordingly, ensuring reliable thread management while maintaining non-blocking UI operation.
Solution Approach 2:
The system performs preliminary thread assignment and coroutine preparation before execution begins. The controller routine pre-manages thread allocation and prepares coroutines for execution, reducing the risk of thread management errors during runtime while enabling smooth background processing.
3Ease of operation
If separate routines are written for different threads, then ease of managing thread-specific logic is improved, but overall system complexity and code volume increase
Solution Approach 1:
The controller routine serves multiple functions: it receives coroutines from originating routines, executes them on different threads, handles thread switching, and manages coroutine responses. This multi-functionality eliminates the need for separate routines for each thread, reducing overall system complexity while maintaining ease of thread-specific logic management.
Solution Approach 2:
The patent merges thread management functionality into a single controller routine that handles all thread-related operations. Instead of having separate routines for each thread, the controller consolidates thread assignment, execution, and switching logic, thereby reducing system complexity while maintaining manageability.
Data Source
AI summary
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.


