Skip to content

Add time support for wasm environments #1865

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

Closed
wants to merge 1 commit into from
Closed

Add time support for wasm environments #1865

wants to merge 1 commit into from

Conversation

Fedeparma74
Copy link
Contributor

This allows ldk to work on wasm targets too, where std::time isn't available. The instant crate emulates the behavior of std::time::SystemTime and std::time::Instant by using javascript functions like Date.now() and performance.now() if the build target is wasm. It's just a wrapper over std::time otherwise. This removes the necessity to use the no-std feature when working with wasm.

@benthecarman
Copy link
Contributor

Concept ACK

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

We definitely shouldn't take a dependency here for all targets. As for the time crate here, I assume it relies on wasm_bindgen providing it some hook to call JS? I'm curious as to the performance of that, we probably don't want to use this in the scorer (cc #1789).

In general, this is maybe an indication we should improve our no-std support - ideally there's minimal pain to just switch to no-std and not have to worry about using a third party crate for something that stdlib is supposed to provide.

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.

3 participants