Closed JiahongShen closed 8 months ago
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.
Describe the feature
I am not an expert of AWS SDK. I shall apologize if there are (stupid) mistakes in the following comments.
As far as I know, S3Client has asynchronous interfaces as stated here. While it in fact sends the request to another newly created thread which does the blocking function call. User can overload this behavior by implementing its own
Executor
, but the blocking function call seems to be unavoidable.The desired behavior is, whenever a time-consuming task is initiated (e.g., communication through network), instead of falling asleep, the thread jumps out of the function with a handle. When the task is finished, the user has the chance to continue the execution with the handle (by polling the handle or some other ways).
Use Case
There are applications that are extremely sensitive to context switch, and want to implement all asynchronous operations in a coroutine-like style. The pain point is that sleeping and usage of CPU cannot be easily separated (by creating a new thread, it only transfers the issue to another thread). The interfaces should be asynchronous without creation of threads or falling asleep.
Proposed Solution
215 mentioned the same issue. The given answer said one can substitute
HttpClient
andExecutor
to use event loops (libuv in that case) at the bottom. While I doubt whether this is true: in case of not rewriting member functions of S3Client, the processing of the response has been taken place before the functions return, making it impossible to be asynchronous.Other Information
I don't think this feature is strongly required by others. Any suggestion on how to implement this kind of features will be helpful.
The best I can imagine is to derive some of the classes and make everything work without changing code in S3Client. If this is impossible (which I guess so), maybe a trivial translation of existing code (e.g., package the rest of function bodies with lambda expressions) can do the job?
Acknowledgements