Skip to content
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

feat: use inspector db directly in js #9

Merged
merged 3 commits into from
Jan 19, 2024
Merged

Conversation

mattsse
Copy link
Contributor

@mattsse mattsse commented Jan 19, 2024

Closes #6

This gets rid of the additional JS service requirement by transmuting the db reference and guarding it against garbage collection.

This applies a similar transmute hack as std::thread::scoped by transmuting the lifetime bound of the DB via a trait object.

The DB wrappers are nullable, once the guard is dropped the actual garbage collected DB reference is also removed

src/tracing/js/bindings.rs Outdated Show resolved Hide resolved
/// Creates a garbage collectible value to the given reference.
///
/// SAFETY; the caller must ensure that the guard is dropped before the value is dropped.
pub(crate) fn r#ref(val: &Val) -> (Self, GcGuard<'_, Val>) {
Copy link
Member

Choose a reason for hiding this comment

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

new_ instead of r#?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we already have new, this calls Self::new with a ref value, the function match the enum variants

Copy link
Member

Choose a reason for hiding this comment

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

Oh I meant new_ref instead of #ref

src/tracing/js/bindings.rs Outdated Show resolved Hide resolved
src/tracing/js/bindings.rs Show resolved Hide resolved
mattsse and others added 2 commits January 19, 2024 16:13
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

lgtm, weird Gc stuff is fine as long as it's private

@mattsse mattsse merged commit eb629fd into main Jan 19, 2024
11 checks passed
@DaniPopes DaniPopes deleted the matt/use-native-db-directly branch January 19, 2024 15:32
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.

Get rid of js db service
2 participants