softbuffer icon indicating copy to clipboard operation
softbuffer copied to clipboard

Implement Send and Sync for softbuffer types

Open notgull opened this issue 1 year ago • 1 comments

Previously, types in softbuffer were !Send and !Sync. However it would be nice if types could be shared across threads. Therefore I've made the following changes:

  • Context<D> is Send+Sync iff D is Send+Sync
  • Surface<D, W> is Send iff D is Send+Sync and W is Send
  • Buffer<'x, D, W> is Send iff D if Send+Sync and W is Send

Materially, I've made the following changes across the backends:

  • X11, Wayland and KMS use Arc for their displays instead of Rc.
  • MacOS uses MainThreadBound to secure windowing resources. This restriction was already implicitly enforced anyhow.
  • Windows uses a subclassing strategy to manage creating and destroying resources. This subclass is applied to windows that are registered into softbuffer, and is then used to manage resources.
  • Web just isn't Send.

Closes #205, still WIP

notgull avatar May 08 '24 03:05 notgull

@jackpot51 Please advise on Redox failures. I'm not familiar enough with Orbital's internals to know if it is thread safe or not.

notgull avatar May 08 '24 03:05 notgull

@jackpot51 Friendly reminder. I'm not familiar enough with Orbital to know how to proceed here.

notgull avatar May 19 '24 22:05 notgull

It seems that there are still bugs in the Windows backend. Sometimes sending a message to a window on another thread doesn't work. Standby while I investigate.

notgull avatar May 30 '24 05:05 notgull

It seems that there are still bugs in the Windows backend. Sometimes sending a message to a window on another thread doesn't work. Standby while I investigate.

Okay, I've set up a new strategy for multithreading on Windows. It's a little hacky but it seems to work.

notgull avatar Jun 01 '24 18:06 notgull

I think we have approval from all platforms, so I'll go ahead and merge this. But I'll wait a week before releasing, that way the people using the master branch directly over Git have a breathing period to find bugs.

notgull avatar Jun 01 '24 18:06 notgull