Skip to content

Make RegionHandlers be Send + Sync by default#318

Open
martin-hughes wants to merge 1 commit into
rust-osdev:mainfrom
martin-hughes:i301-send-sync-regions
Open

Make RegionHandlers be Send + Sync by default#318
martin-hughes wants to merge 1 commit into
rust-osdev:mainfrom
martin-hughes:i301-send-sync-regions

Conversation

@martin-hughes

Copy link
Copy Markdown
Contributor

This fixes #301 in my preferred way (the Send interpreter remains called Interpreter) but still allows for an easy non-send interpreter as well.

NB: The function signature of install_region_handler changes to require a Box to be passed to it. This was the simplest way of avoiding a compiler error about Sized. Plus it relieves that function of the responsibility to construct a Box 😉

I've done a bunch of testing to make sure this works as expected, but there's no easy way to write "compile fail" tests except as doctests - and the need for a dummy RegionHandler just makes it look very messy. So I assert to you that it works correctly!

Ideally I'd like to remove the unsafe impl blocks for Interpreter, but there's more work to do first (see also #307). This PR addresses probably the most obvious unsafety of pretending that all RegionHandlers are Send + Sync.

Preserve the option to have non Send/Sync RegionHandlers for anyone who
finds that useful.

There is an API change in `install_region_handler` - but region handlers
are not currently supported so this should not be an issue.
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.

Interpreter<H> isn't safely Send or Sync because of dyn RegionHandler

1 participant