mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
implement broadcastchannel
This commit is contained in:
parent
145c89a2d4
commit
eb21d5f738
32 changed files with 763 additions and 216 deletions
|
@ -171,6 +171,13 @@ impl PipelineNamespace {
|
|||
}
|
||||
}
|
||||
|
||||
fn next_broadcast_channel_router_id(&mut self) -> BroadcastChannelRouterId {
|
||||
BroadcastChannelRouterId {
|
||||
namespace_id: self.id,
|
||||
index: BroadcastChannelRouterIndex(self.next_index()),
|
||||
}
|
||||
}
|
||||
|
||||
fn next_blob_id(&mut self) -> BlobId {
|
||||
BlobId {
|
||||
namespace_id: self.id,
|
||||
|
@ -380,6 +387,42 @@ impl fmt::Display for MessagePortRouterId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct BroadcastChannelRouterIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(BroadcastChannelRouterIndex);
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct BroadcastChannelRouterId {
|
||||
pub namespace_id: PipelineNamespaceId,
|
||||
pub index: BroadcastChannelRouterIndex,
|
||||
}
|
||||
|
||||
impl BroadcastChannelRouterId {
|
||||
pub fn new() -> BroadcastChannelRouterId {
|
||||
PIPELINE_NAMESPACE.with(|tls| {
|
||||
let mut namespace = tls.get().expect("No namespace set for this thread!");
|
||||
let next_broadcast_channel_router_id = namespace.next_broadcast_channel_router_id();
|
||||
tls.set(Some(namespace));
|
||||
next_broadcast_channel_router_id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for BroadcastChannelRouterId {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let PipelineNamespaceId(namespace_id) = self.namespace_id;
|
||||
let BroadcastChannelRouterIndex(index) = self.index;
|
||||
write!(
|
||||
fmt,
|
||||
"(BroadcastChannelRouterId{},{})",
|
||||
namespace_id,
|
||||
index.get()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct BlobIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(BlobIndex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue