Skip to content

Commit

Permalink
implement Send and Sync for Ftdi
Browse files Browse the repository at this point in the history
The auto traits `Send` and `Sync` were not implemented because `Ftdi`
contains a (type aliased) raw pointer (`FT_HANDLE`). `Send` and `Sync`
are now implemented explicitly, making it possible to use `Ftdi` in
different threads.
  • Loading branch information
Icxolu authored Aug 28, 2022
1 parent cbb25bf commit 33e8bc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Updated the edition from 2018 to 2021.
- Implement `Send` and `Sync` for `Ftdi`.

## [0.32.0] - 2021-11-07
### Added
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,15 @@ impl Drop for Ftdi {
}
}

// Safety: Unfortunatly there is no clear statement about the thread safety of
// the D2XX library in the official programming guide. But there are mentions
// about thread-safety fixes in the release notes of the driver, which suggests
// that the library is indeed thread synchronized. It would also be quite
// strange if the D2XX driver could not be used across threads, but the VCP
// driver can.
unsafe impl Send for Ftdi {}
unsafe impl Sync for Ftdi {}

macro_rules! impl_boilerplate_for {
($DEVICE:ident, $TYPE:expr) => {
impl FtdiCommon for $DEVICE {
Expand Down

0 comments on commit 33e8bc2

Please sign in to comment.