Skip to content

Make the wrappers around agile COM objects Send and Sync - #103

Merged
HEnquist merged 5 commits into
drop-umbrella-windowsfrom
send-sync
Dec 3, 2026
Merged

HEnquist merged 5 commits into
drop-umbrella-windowsfrom
send-sync

Conversation

@HEnquist

Copy link
Copy Markdown
Owner

Closes #95.

  • Send + Sync for every wrapper except Device and DeviceCollection, which stay !Send
  • The safety contracts of Device::from_raw and AudioClient::from_raw require the object, and everything it hands out, to be agile
  • Device tests check that the objects are agile (IAgileObject or the free-threaded marshaler), and that IMMDevice is not
  • Compile time check for Send and Sync in tests/public_api.rs

All wrappers except Device and DeviceCollection hold objects that implement
IAgileObject or marshal with the free-threaded marshaler, so they can be
used from any thread. Device and DeviceCollection stay !Send, since
IMMDevice and IMMDeviceCollection are neither agile nor marshalable.

- The safety contracts of Device::from_raw and AudioClient::from_raw
  require the object, and everything it hands out, to be agile.
- New device tests check that the objects are agile, and that IMMDevice
  is not.
- A compile time check in public_api.rs for Send and Sync.
- Device::as_raw no longer says that the interfaces activated from the
  device are tied to its apartment, which they are not.
@HEnquist HEnquist changed the title Make the wrappers around agile COM objects Send and Sync Make the wrappers around agile COM objects Send and Sync Nov 30, 2026
@HEnquist

Copy link
Copy Markdown
Owner Author

@LastExceed does this look alright to you?

@LastExceed LastExceed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First (and probably last) code review done entirely on phone😬

Comment thread tests/device/agility.rs Resolved
Comment thread tests/device/agility.rs Resolved
Comment thread src/api.rs Resolved
Comment thread src/api.rs Resolved
Comment thread tests/device/agility.rs Resolved
…-sync

# Conflicts:
#	tests/device/bindings.rs
#	tests/public_api.rs
- agility() returns an Agility enum instead of a string
- assert_agile no longer prints, the output was never shown
- Explain that device_is_not_agile is the negative control
- "in the apartment" rather than "on the apartment"
Comment thread tests/device/agility.rs Resolved
@HEnquist
HEnquist merged commit 109e833 into drop-umbrella-windows Dec 3, 2026
3 checks passed
@HEnquist HEnquist mentioned this pull request Dec 3, 2026
7 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants