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

Implement MessagePort and MessageChannel #16622

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Detach port on closure and check for detached during transfer

  • Loading branch information
KiChjang committed Jun 11, 2019
commit 498fbefe00cec7ca359168849d5488c3b19e4dab
@@ -217,6 +217,10 @@ unsafe extern "C" fn write_transfer_callback(
extra_data: *mut u64,
) -> bool {
if let Ok(port) = root_from_handleobject::<MessagePort>(Handle::from_raw(obj)) {
if let Some(true) = port.detached() {
return false;
}

*tag = StructuredCloneTags::MessagePort as u32;
*ownership = TransferableOwnership::SCTAG_TMO_CUSTOM;
if port.transfer(closure, content, extra_data) {
@@ -364,6 +364,10 @@ impl MessagePortMethods for MessagePort {

/// <https://html.spec.whatwg.org/multipage/#dom-messageport-close>
fn Close(&self) {
// Step 1
self.detached.set(true);

// Step 2
let maybe_port = {
let internal = self.message_port_internal.lock().unwrap();
let mut maybe_port = internal.entangled_port.borrow_mut();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.