Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSeparate waking the event loop, from communicating with Compositor #17068
Conversation
33227ca
to
ab7a4d0
|
r? @paulrouget |
01170ae
to
633ca33
|
UPDATE: also added the implementation for the cef port... |
|
Looks good to me. There are some nits to address. Also, I'm not 100% sure you need to use Box. Once these addressed, I'd like @asajeffrey to take a look as well. |
| pub trait CompositorReceiver : 'static { | ||
| /// Receives the next message inbound for the compositor. This must not block. | ||
| fn try_recv_compositor_msg(&mut self) -> Option<Msg>; | ||
| /// Synchronously waits for, and returns, the next message inbound for the compositor. | ||
| fn recv_compositor_msg(&mut self) -> Msg; | ||
| } | ||
|
|
||
| /// Used to wake up the event loop, provided by the Servo port. |
This comment has been minimized.
This comment has been minimized.
| /// This is part of the windowing system because its implementation often involves OS-specific | ||
| /// magic to wake the up window's event loop. | ||
| fn create_compositor_channel(&self) -> (Box<CompositorProxy + Send>, Box<CompositorReceiver>); | ||
| /// Creates a thread-safe object to wake the up window's event loop. |
This comment has been minimized.
This comment has been minimized.
| @@ -273,6 +273,36 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static { | |||
| } | |||
| } | |||
|
|
|||
| fn create_compositor_channel(event_loop_riser: Box<compositor_thread::EventLoopRiser>) | |||
| -> (Box<CompositorProxy + Send>, Box<CompositorReceiver>) { | |||
This comment has been minimized.
This comment has been minimized.
paulrouget
May 30, 2017
Contributor
(Box<CompositorProxy + Send>, Box<CompositorReceiver>): do we still need boxed objects? Now that the implementation is not in the embedder anymore, we don't need a trait, we could use a regular struct (like BrowserCompositorProxy). It would then have a known size, and I don't think we would then need to box these?
I didn't look too closely, so maybe I'm wrong.
| // Send a message and kick the OS event loop awake. | ||
| if let Err(err) = self.sender.send(msg) { | ||
| // NOTE: how to add the warn! macro? | ||
| //warn!("Failed to send response ({}).", err); |
This comment has been minimized.
This comment has been minimized.
| } as Box<CompositorProxy+Send>, | ||
| box receiver as Box<CompositorReceiver>) | ||
| fn create_event_loop_riser(&self) -> Box<EventLoopRiser> { | ||
| struct CefEventLoopRiser {} |
This comment has been minimized.
This comment has been minimized.
| box receiver as Box<CompositorReceiver>) | ||
| box GlutinEventLoopRiser { | ||
| window_proxy: window_proxy, | ||
| } as Box<EventLoopRiser + Send> |
This comment has been minimized.
This comment has been minimized.
| fn clone(&self) -> Box<EventLoopRiser + Send> { | ||
| box GlutinEventLoopRiser { | ||
| window_proxy: self.window_proxy.clone(), | ||
| } as Box<EventLoopRiser + Send> |
This comment has been minimized.
This comment has been minimized.
633ca33
to
f630c34
03b225d
to
bab8f3a
|
@paulrouget Ok, I replaced the compositor related traits with structs, and addressed the other comments too... I'm wondering if we need to add some sort of "clone" method to |
| } as Box<CompositorProxy+Send>, | ||
| box receiver as Box<CompositorReceiver>) | ||
| fn create_event_loop_riser(&self) -> Box<EventLoopRiser> { | ||
| struct CefEventLoopRiser |
This comment has been minimized.
This comment has been minimized.
| } | ||
| fn clone(&self) -> Box<EventLoopRiser + Send> { | ||
| box CefEventLoopRiser { | ||
| } as Box<EventLoopRiser + Send> |
This comment has been minimized.
This comment has been minimized.
|
Thank you Greg. This looks good to me now (beside a nit). I'd like to get a review from Alan. @asajeffrey - this is the first step to clarify the Embedder <-> Constellation communication. Can you take a look too? |
|
LGTM, I just have an annoying bikeshedding name change. |
| fn clone_compositor_proxy(&self) -> Box<CompositorProxy + 'static + Send>; | ||
|
|
||
| /// Used to wake up the event loop, provided by the servo port/embedder. | ||
| pub trait EventLoopRiser : 'static + Send { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gterzian
Jun 5, 2017
Author
Member
How about EventLoopAwaker, so that we have a noun? https://en.wiktionary.org/wiki/awaker
|
715e910
to
3a693c7
|
Ok, |
|
It looks like approving in Github isn't enough, and somebody needs to do a r+ at the bot... |
|
@bors-servo r+ |
|
|
|
Hmm, I wonder why bors reckons this is still a WIP. Is it the unchecked boxes in the PR description? |
|
Probably the title. I changed it. Do you need to re-approve? |
|
@bors-servo r+ |
|
|
|
@paulrouget @asajeffrey thanks for the review. |
Separate waking the event loop, from communicating with Compositor <!-- Please describe your changes on the following line: --> @paulrouget first step of #15934, Glutin only for now, please take a look... If this makes sense, I will also update the code for ports other than Glutin... One question: one do I add the `warn!` macro to `servolib`? Also perhaps we would also want to add `box`, since I had to switch to using `Box::new`... --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17068) <!-- Reviewable:end -->
|
|
|
Thank you @gterzian |
|
@gterzian thanks! |
gterzian commentedMay 28, 2017
•
edited
@paulrouget first step of #15934, Glutin only for now, please take a look...
If this makes sense, I will also update the code for ports other than Glutin...
One question: one do I add the
warn!macro toservolib? Also perhaps we would also want to addbox, since I had to switch to usingBox::new..../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is