Open CeSun opened 3 years ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Author: | CeSun |
---|---|
Assignees: | - |
Labels: | `area-System.Threading`, `untriaged` |
Milestone: | - |
Is there any progress?
but I want to run the coroutines on a single thread to ensure the safety of critical resources.
The server QPS is only 60...
I believe this is actually the reason. Cross-thread scheduling is costful.
I am a C++ programmer, mainly developing stateful services. In C++, I use the network to drive asynchronous callback functions. The program is single-threaded. But the callback is really annoyed. So I want to use c# to do this work and replace the callback function with await/async.
The default c# coroutine will take idle threads from the thread pool to run, but I want to run the coroutines on a single thread to ensure the safety of critical resources.
I did the following:
https://github.com/CeSun/Server/blob/master/Frame/SingleThreadSynchronizationContext.cs
The Run function only takes 10 to 20 functions to execute in order to guarantee the number of cycles per second. I will do some update operations before the loop starts. For example, the timer may need to be updated here.
But the final performance is not high, I want to know if it is written incorrectly and does not meet the specifications. The server QPS is only 60...