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

fromPtr should have a more explicit name that points out use of mask_ #158

Open
1 task
nh2 opened this issue Oct 19, 2024 · 0 comments
Open
1 task

fromPtr should have a more explicit name that points out use of mask_ #158

nh2 opened this issue Oct 19, 2024 · 0 comments

Comments

@nh2
Copy link
Collaborator

nh2 commented Oct 19, 2024

fromPtr $ do ... uses mask_, thus making anything it wraps uninterruptible.

This means that common code such as

fromPtr $ [C.block|Mat * {
  // long-running C++ computation here
  }|]

will hang, not properly reacting to Ctrl+C, timeout, async cancellation, or other async exceptions.

Of course the C/C++ part itself cannot be interrupted anyway because it is a foreign call (unless foreign import ccall interruptible is used, which it isn't and which would need the called code to provide the necessary guarantees).

But the user of fromPtr should be made more explicitly aware that mask_ is going on, so that they ensure to not write any unnecessary Haskell code under it.

Solution

  • fromPtr is in OpenCV.Internal.C.Types and doesn't seem to be re-exported to public APIs, so I think we should rename it to fromPtrWithMask, and deprecate the old name (but keep it forever).
@nh2 nh2 changed the title fromPtr and uses are bad (uninterruptible) because they mask_ fromPtr should have a more explicit name that points out use of mask_ Oct 19, 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

No branches or pull requests

1 participant