mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
re-structure blob, structured serialization
This commit is contained in:
parent
7aa68c8fe7
commit
6e8a85482c
31 changed files with 997 additions and 489 deletions
|
@ -170,6 +170,13 @@ impl PipelineNamespace {
|
|||
index: MessagePortRouterIndex(self.next_index()),
|
||||
}
|
||||
}
|
||||
|
||||
fn next_blob_id(&mut self) -> BlobId {
|
||||
BlobId {
|
||||
namespace_id: self.id,
|
||||
index: BlobIndex(self.next_index()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thread_local!(pub static PIPELINE_NAMESPACE: Cell<Option<PipelineNamespace>> = Cell::new(None));
|
||||
|
@ -373,6 +380,37 @@ impl fmt::Display for MessagePortRouterId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct BlobIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(BlobIndex);
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct BlobId {
|
||||
pub namespace_id: PipelineNamespaceId,
|
||||
pub index: BlobIndex,
|
||||
}
|
||||
|
||||
impl BlobId {
|
||||
pub fn new() -> BlobId {
|
||||
PIPELINE_NAMESPACE.with(|tls| {
|
||||
let mut namespace = tls.get().expect("No namespace set for this thread!");
|
||||
let next_blob_id = namespace.next_blob_id();
|
||||
tls.set(Some(namespace));
|
||||
next_blob_id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for BlobId {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let PipelineNamespaceId(namespace_id) = self.namespace_id;
|
||||
let BlobIndex(index) = self.index;
|
||||
write!(fmt, "({},{})", namespace_id, index.get())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct HistoryStateIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(HistoryStateIndex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue