Skip to content

safe interface for tracing #731

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
extrawurst opened this issue Jul 23, 2021 · 2 comments · Fixed by #732
Closed

safe interface for tracing #731

extrawurst opened this issue Jul 23, 2021 · 2 comments · Fixed by #732

Comments

@extrawurst
Copy link
Contributor

@alexcrichton like mentioned in #696 I would like to add a safe wrapper for git_trace_set. since it does not take a custom payload I can only imagine doing this via a global variable to store the user callback. this requires Mutex protection which in turn requires lazy_static

a) is that ok for you to add as a dependency?
b) do we have an alternative way to do this?
c) do we say such stuff belongs into user code or a utility crate?

@alexcrichton
Copy link
Member

I think this could probably be done with an AtomicUsize rather than a mutex? (since we'd just cast a function pointer to a usize and put the value in the global AtomicUsize)

@extrawurst
Copy link
Contributor Author

I think this could probably be done with an AtomicUsize rather than a mutex? (since we'd just cast a function pointer to a usize and put the value in the global AtomicUsize)

damn you are right - casting the usize to a pointer - that feels so dirty! I love it - PR incoming

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 a pull request may close this issue.

2 participants