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

Accept closures in highgui_set_mouse_callback #118

Open
vadixidav opened this issue Mar 8, 2019 · 3 comments
Open

Accept closures in highgui_set_mouse_callback #118

vadixidav opened this issue Mar 8, 2019 · 3 comments

Comments

@vadixidav
Copy link

In highgui_set_mouse_callback currently it is not possible to pass it a closure. By storing an arbitrary dyn Fn type in the Box inside its definition, it should be possible to accept an arbitrary closure to ease callback handling.

@Pzixel
Copy link
Collaborator

Pzixel commented Mar 12, 2019

Making <F: FnMut> would be enough.

@vadixidav
Copy link
Author

@Pzixel That is true, but we then have to turn it into a dyn FnMut so that we can pass it to C as a single pointer type since the type is erased. We will find out if we can use FnMut based on if any data races can occur in the code. I think there is a good chance we can accept FnMut. We can only do that if the C code never creates a data race. If it does then we will need to use Fn. If C makes a cross thread data race then we will also need to force it to be Send and Sync.

@vadixidav
Copy link
Author

I actually already fixed this in #117. Once that is merged we can close this.

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

2 participants