Skip to content

Implement optimized dispatch_once #1

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
SSheldon opened this issue Jun 1, 2015 · 1 comment
Closed

Implement optimized dispatch_once #1

SSheldon opened this issue Jun 1, 2015 · 1 comment

Comments

@SSheldon
Copy link
Owner

SSheldon commented Jun 1, 2015

dispatch_once_f is redefined as:

void _dispatch_once_f(dispatch_once_t *predicate, void *context, dispatch_function_t function)
{
    if (__builtin_expect(*predicate, ~0l) != ~0l) {
        dispatch_once_f(predicate, context, function);
    }
}

This requires the expect builtin, which isn't exposed as an intrinsic in Rust. Implementing this would be possible if rust-lang/rfcs#918 is accepted and implemented.

@SSheldon
Copy link
Owner Author

This is probably doable with the #[cold] attribute: https://doc.rust-lang.org/stable/reference.html#function-only-attributes

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

No branches or pull requests

1 participant