-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Asynchronous Code Design #3
Comments
I actually tried using async and await, but I found it extremely hard to use. Mainly I think it was because the git and ssh libraries don't support native async, so getting those to work like async functions just were not working. For some reason, the awaits would actually not wait, because the async task would never actually start. Maybe I was doing this wrong, but I just could not get it working. Also, a lot of tools in this repository are just testing ones I've been writing, and designed to run on a PC anyway. So a little bit of extra resources shouldn't be a big deal. However, on the RoboRIO side performance is essential. But most of the threads there are not short threads, but are indefinitely running threads. I think the only pool based threads are already using thread pools. All the other ones, like the network tables and driver station loops run forever anyway, so they should be threads, at least I think. |
Every time I've used async/await it's been super easy, but it makes sense that it depends on which libraries you're using. We should at least be using ThreadPools on the user side. We don't need this level of threading and we don't need this amount of control over the methods. Additionally, we should not be more resource intensive than we need to be just because we can. I already did a sweep on the WPILib project and switched the ones that should be threadpooled over to the ThreadPool. |
As of right now, the only user side code is over in the FRC Extension repository. That could be switched over to a thread pool, but since reading around it looks like thread pools are limited to 25 per cpu per applicaiton, and that code runs inside of VS, would we run into pool issues inside of visual studio? EDIT: Looking through some documentation, it looks like thread pool is not recommended for threads that block for extend periods of time. I know most of the ones connecting to the RIO each block for 5-10 seconds while trying to actually connect. Would that be considered extended? |
I guess the RoboRIO tool in here is used by that, but it still could run into the same issue as above, while running inside of visual studio. |
For the tools that run inside of Visual Studio, we should use Tasks because their underlying scheduler, the |
In VS the entire deploy loops has to be run in its own task or thread. If not, it blocks the entire VS windows for the 20+ seconds it deploys, which is unacceptable. Right now its a thread, but if a task would be better we should switch to that. |
I'll take a stab at fixing up the deploy scripts. |
I've noticed that there is a lot of use of the
Thread
class in our projects here, especially in this repository. TheThread
class is actually very resource intensive (mainly because threads are resource intensive). We should take a look at the asynchronous facilities and patterns that the .NET framework supplies to simplify the code and reduce resource use.Here are the underlying structures in .NET that I know of:
Thread
sThreadPool
sTask
sThe following are the patterns used:
Task
class mentioned above.The text was updated successfully, but these errors were encountered: