webp-animation icon indicating copy to clipboard operation
webp-animation copied to clipboard

implement Send on encoder and decoder wrappers

Open gdesmott opened this issue 1 year ago • 3 comments

Make API more convenient to use.

gdesmott avatar May 07 '24 11:05 gdesmott

Thank you for your pull request!

I see that you've proposed adding an unsafe impl Send for Decode/EncodeWrapper's. Given the potential risks associated with unsafe code and multi-threading, could you please provide a safety comment in the code?

It would be helpful to explain why this implementation is safe, particularly in light of the following considerations:

  • The (libwebp) seems not to mention specific guarantees regarding thread safety for the components used in this struct.

The Decoder and Encoder in this library manage the access to the pointer, and don't expose any concurrent safety hazards. But wondering if the transfer between threads itself is ok.

blaind avatar May 15 '24 13:05 blaind

But wondering if the transfer between threads itself is ok.

Tbh I'm not totally sure either. Send is usually ok, but if you do not know about this either it may be best to check with libwebp upstream.

gdesmott avatar May 15 '24 13:05 gdesmott

Thanks. I'll try to check it out. Agreed, Send should be ok here but want to err on the safe side.

blaind avatar May 15 '24 14:05 blaind