winreg-rs
winreg-rs copied to clipboard
Implement `Send` for `Transaction`
I am not absolutely sure about this, but as far as I can tell a transaction is just a handle. Can a transaction be made Send
just like RegKey
?
Yes, looks like HANDLE
should be thread safe
https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/handle.rs
But anyway I'd want to test this kind of things before releasing it.
Do you have any particular use case?
Maybe a peace of code, which makes use of Send
able Transaction
/RegKey
?
I actually changed the code that required this and ended up not needing it anymore. In my case I was embedding a transaction as a value in gluon. Gluon can run on multiple threads so values you want to expose have to be Send
. I'd imagine something like this (runtimes that require Send
because they are multithreaded) would probably be the only real use case.
But anyway I'd want to test this kind of things before releasing it.
Yeah, I totally understand. I'm not quite sure how one would test this, though. I can only tell you that for the few times I used it it worked just fine, but that doesn't mean much of course. The windows docs aren't really clear on this unfortunately, in a lot of other places they explicitly state that a handle is thread-safe.
The best I could find is this paragraph:
Transactions are not the same as threads. Multiple threads or processes can be a part of a single transaction. Conversely, a thread can be a part of several different transactions at different times.
Which I guess implies that transaction handles are thread-safe.