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

Reduce FOREVER from 290 to 200 years #2938

Merged
merged 1 commit into from
Mar 31, 2024

Conversation

Chainfire
Copy link
Contributor

Prevents wrap observed in emcc, causing find_max_global to exit immediately unless a custom (and non-wrapping) max_runtime is provided.

Prevents wrap observed in emcc, causing find_max_global to exit immediately unless a custom (and non-wrapping) max_runtime is provided.
@Chainfire
Copy link
Contributor Author

Problem observed when using dlib compiled to 32-bit WebAssembly using Emscripten (emcc) and run in the browser.

I'm not sure what the real reason for it is, but trying out the code listed below (not mine, found on StackOverflow) in multiple different browsers all output the max addition was ~ 238 years.

Perhaps a better solution would eventually be using steady_clock::time_point::max() somehow, but using 200 instead of 290 years might be acceptable for now.

    using namespace std::chrono;
    using namespace std;
    using days = duration<int, ratio<86400>>;
    using years = duration<double, ratio_multiply<ratio<146097, 400>, days::period>>;
    cout << years{steady_clock::time_point::max() - steady_clock::now()}.count() << " years to go\n";

@davisking
Copy link
Owner

Cool, yeah thanks. This is a good solution.

@davisking davisking merged commit 1db5a38 into davisking:master Mar 31, 2024
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