-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fold the allocator back into the mnemos repo #54
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This branch adds `fmt::Debug`, `fmt::Display`, and `fmt::Pointer` impls to `HeapArc`, `HeapArray`, and `HeapFixedVec`, as appropriate. The `Display` and `Debug` impls forward to the inner types, and require `T: fmt::Debug` or `T: fmt::Display`; on the other hand, the `fmt::Pointer` impls are always present regardless of `T` and display the address of the heap allocation. I wanted the `fmt::Pointer` impls specifically for #4, so that the bbqueue traces could include the address of the shared buffer, but they didn't exist at the time, so I thought they would be nice to add.
Add `fmt` trait impls for heap containers
This commit fixes some implementations of `Send` and `Sync` for the `HeapFoo` container types that were either wrong or missing. In particular: - No heap container types currently implement `Sync`. This is unfortunate when trying to spawn Tokio tasks in `melpomene`, since tasks must be `Send + Sync` to be spawned. I've added `Sync` impls for all the heap types. - The `Send` implementations for `HeapBox`, `HeapArray`, and `HeapFixedVec` do not require that `T: Send`. This is incorrect; sending a `HeapBox<T>` where `T: !Send` is functionally equivalent to sending a `T`. Note that (for ereference) `alloc::boxed::Box`'s `Send` impl [requires `T: Send`][1]. - The `Send` and `Sync` impls for `HeapArc<T>` both require `T: Send + Sync`, since sending an `Arc<T>` across threads is morally equivalent to sending an `&T`. Again, these are the same bounds as the `Send` and `Sync` [impls for `alloc::sync::Arc`][2]. [1]: https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html#impl-Send [2]: https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html#impl-Send
containers: fix missing and wrong `Send` + `Sync` impls
Update mycelium deps
This branch adds new APIs for lower-level manual memory management. The `Heap::allocate_raw` method takes a user-provided `Layout` and allocates an unsized, untyped allocation for that layout. The `unsafe` free function `deallocate_raw` deallocates a pointer and `Layout` pair that were allocated by `allocate_raw`. Together, these (unsafe) APIs allow the implementation of user-defined types which manually manage a dynamically-sized allocation, which was not previously possible with `mnemos-alloc`. Closes #4 Note that unlike the proposed interface in #4, this does *not* allow a `HeapBox` to own a `!Sized` type. I'd like to figure that out eventually, but it's somewhat orthogonal to the central concern of "how do I allocate a raw `Layout`? Co-authored-by: James Munns <james@onevariable.com>
* Correct alignment of unsized items * Address review comments
✅ Deploy Preview for merry-scone-cc7a60 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
hawkw
approved these changes
Jun 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's goooooo
i love how the first commit in this history is "Export from mnemos super repo" |
jamesmunns
added a commit
that referenced
this pull request
Jun 4, 2023
Monorepo the `forth3` project. Keeps forth3 and f3repl, forthboy's parts now live in https://github.com/tosc-rs/teletype/. Same deal as #54.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This undoes a decision from about a year ago to move the allocator into its own crate.
Merged as an "unrelated history", meaning all history is retained.
This should NOT be a squash merge.