We've been using OSHI for a long time for logging system information, but we now wanted to take it a step further and start using the information gathered by OSHI for decisions/evaluations in the code.
I took a quick look in the code and can see that there is not handling of thread-safety in OSHI at all as far as I can see. Unfortunately our application is multi-threaded, and considering how slow it is to gather all the information needed, it's not really viable to do that every time an evaluation using this information is due.
Has this at all been considered? It shouldn't be that hard to use immutable classes where possible and use synchronization on the rest (all classes with setters). It will require changes to most classes though, so it's a comprehensive in that sense.
I could consider making a PR for this, but unfortunately I'm still stuck at 3.x (since we still support Java 7) and I doubt you'd be interested in merging something like that in 3.x? Also, I don't know if you'd be interested in having thread-safety in the first place, although I think it would make a lot of sense because of the time it takes to gather the information.
I'd love to make OSHI more thread safe, and would consider updating the 3.X branch. Unfortunately I personally don't have the expertise nor bandwidth to make that happen. See the discussion on #797. If you are able to make the necessary changes I'd be happy to merge them.
Good to hear. I won't be right now, but now I know that I have a path to do this when I get there :+1:
Closing this as we will implement thread safety in 4.1.0.
I understand you're still on JDK7 and the 3.x branch, but I think the work involved to update 3.x exceeds the work that it would take to backport 4.x to Java 7. And if you think that's a useful endeavor, I invite you to open a new issue about it!
Most helpful comment
I'd love to make OSHI more thread safe, and would consider updating the 3.X branch. Unfortunately I personally don't have the expertise nor bandwidth to make that happen. See the discussion on #797. If you are able to make the necessary changes I'd be happy to merge them.