Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Questions on WPILib components thread usage (http://www.chiefdelphi.com/forums/showthread.php?t=101394)

Varriount 28-01-2012 15:36

Questions on WPILib components thread usage
 
Hello, my team has just started programming in java, and we've studied the documentation of WPILib, however some of us still have questions regarding thread safety and thread usage of WPILib's components.
What, if any, components of WPILib use threads? (Not including java's native thread library)
Does the VM on the cRio do any sort of automatic background threading or threading without the explicit usage of thread objects, in such a way that we would need to ensure the thread safety of our code?

Chiller 28-01-2012 18:26

Re: Questions on WPILib components thread usage
 
Yes, all screw holes are threaded.

Varriount 29-01-2012 12:29

Re: Questions on WPILib components thread usage
 
Um, excuse me? Chiller, could you clarify?

krieck 29-01-2012 15:00

Re: Questions on WPILib components thread usage
 
Digging through the WPILIBJ source code, I can see a couple of threads created, but only for minor asynchronous communication. Preferences, for instance, are saved and retrieved in a separate thread. Some of the networktable methods manage connections in separate threads.

The actual robot code seems to run entirely in a single thread.

Thread-safety is a good topic to discuss and an important discipline to remember, but I think that it will not be an issue in your robot code.

Varriount 29-01-2012 15:20

Re: Questions on WPILib components thread usage
 
Thanks for the information krieck. It's one less thing for our team to worry about. What about the command system? One would think that to run commands synchronously, they would be run in a seperate thread?

Sunstroke 29-01-2012 16:12

Re: Questions on WPILib components thread usage
 
Quote:

Originally Posted by Varriount (Post 1115916)
Thanks for the information krieck. It's one less thing for our team to worry about. What about the command system? One would think that to run commands synchronously, they would be run in a seperate thread?

They are not, instead commands are just run in order in a single thread. Because of the iterative nature of commands though, this makes the run concurrently.

However, there is a downside because if one of your commands calls sleep or whatnot in its execute method, then all the other commands will have to wait for yours to finish before they do anything.

Ether 29-01-2012 16:45

Re: Questions on WPILib components thread usage
 
Quote:

Originally Posted by Varriount (Post 1115916)
Thanks for the information krieck. It's one less thing for our team to worry about. What about the command system? One would think that to run commands synchronously, they would be run in a seperate thread?

Did you mean concurrently?

Varriount 29-01-2012 16:47

Re: Questions on WPILib components thread usage
 
Quote:

Originally Posted by Ether (Post 1115966)
Did you mean concurrently?

Ah, yes, I did mean concurrently, sorry.


All times are GMT -5. The time now is 22:22.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi