GuillaumeGomez / sysinfo

Cross-platform library to fetch system information
MIT License
2.1k stars 313 forks source link

`Process` is does not implement `Send + Sync` on windows #148

Closed bkchr closed 5 years ago

bkchr commented 5 years ago

Hey, on Linux the Process struct implements Send + Sync, but not on Windows. We have the following bug report.

After looking into the Process code for Windows, I think that HANDLE is the problem. You probably need to create a pointer wrapper that makes HANDLE SEND + SYNC.

GuillaumeGomez commented 5 years ago

It's part of the problem, yes. However, Process cannot be used safely between threads. I'll make another check for linux but I think it shouldn't be Send+Sync either. I need it internally so I can perform faster computations but that's it.

To fix your issue, you'll have to wrap it inside a Mutex I guess. I'll certainly modify the internal code so that Process doesn't implement Send+Sync anymore.

Sorry for the confusion!

bkchr commented 5 years ago

Ahh okay. Good to know :) Thanks for the fast answer! Yeah, then we will adapt our code accordingly.

GuillaumeGomez commented 5 years ago

I opened an issue about it if you want to follow the evolution: #149.

GuillaumeGomez commented 5 years ago

@bkchr: I think you were right: implementing Send and Sync traits seem like a better solution so let's go for it. I'll send the PR in the next hours.