You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to propose implementing the Sync trait for the SerialPort trait. The primary blocker for this seems like COMPort does not automatically implement Sync due to the HANDLE type using a raw pointer. TTYPort already implements Sync because it uses RawFd which is simply a primitive type.
Upon investigation, I found the Rust standard library contains the following statement about Windows HANDLE types:
// The Windows [`HANDLE`] type may be transferred across and shared between// thread boundaries (despite containing a `*mut void`, which in general isn't// `Send` or `Sync`).//// [`HANDLE`]: std::os::windows::raw::HANDLE#[stable(feature = "io_safety", since = "1.63.0")]unsafeimplSendforOwnedHandle{}// ...#[stable(feature = "io_safety", since = "1.63.0")]unsafeimplSyncforOwnedHandle{}
Maybe we could do the same for the COMPort type by implementing the Sync trait similarly. This would allow SerialPort to also implement Sync, enabling usage in multi-threaded contexts. I believe this is sound because IO-related operations still require exclusive access to &mut Self to perform.
The text was updated successfully, but these errors were encountered:
I would like to propose implementing the
Sync
trait for theSerialPort
trait. The primary blocker for this seems likeCOMPort
does not automatically implementSync
due to theHANDLE
type using a raw pointer.TTYPort
already implementsSync
because it usesRawFd
which is simply a primitive type.Upon investigation, I found the Rust standard library contains the following statement about Windows
HANDLE
types:Maybe we could do the same for the
COMPort
type by implementing theSync
trait similarly. This would allowSerialPort
to also implementSync
, enabling usage in multi-threaded contexts. I believe this is sound because IO-related operations still require exclusive access to&mut Self
to perform.The text was updated successfully, but these errors were encountered: