网站开发与设计专业岳阳网站建设设计
- 作者: 五速梦信息网
- 时间: 2026年03月21日 07:34
当前位置: 首页 > news >正文
网站开发与设计专业,岳阳网站建设设计,网站建设和运行遇到的问题,模板网站在只有mojo的情况下#xff0c; 进程间通信都是靠unix 域套接字来完成了#xff0c;由于这种方式比较低效#xff0c;并且不够灵活#xff0c;后来引入了ipcz。 但是系统中基本上使用mojo做进程间通信#xff0c;想要一步到位迁移到ipcz系统是比较困难的。 所以chrome团队…在只有mojo的情况下 进程间通信都是靠unix 域套接字来完成了由于这种方式比较低效并且不够灵活后来引入了ipcz。 但是系统中基本上使用mojo做进程间通信想要一步到位迁移到ipcz系统是比较困难的。 所以chrome团队采用了一种折中的方法利用原来mojo的channel进行socket通信作为控制消息和唤醒机制。 使用ipcz 来实现共享内存和路由机制。另外由于chrome是一个面向多操作系统的任务对于不同操作系统使用不同的代码实现这样就要求抽取出操作系统相关的实现。这样使得现有代码非常混乱。另外ipcz系统希望减少耦合尽量少的暴露实现细节以及方便序列化使用handle句柄代理不同层的对象。
ipcz主要有四个模块 1、ipcz上层third_party/ipcz 目录。 handle 为IpczHandle。 实现Node、NodeLink、RouterLink、Portal、NodeConnector、Router、Parcle 等对象。架空mojo的Node 和Port 2、ipcz driver层mojo/core/ipcz_driver目录。handle 为 IpczDriverHandle。 实现Transportipcz层和mojo层的粘合剂利用mojo层的通信能力服务ipcz层。序列化传输能力。 3、mojo 层mojo/core目录。handle 为 MojoHandle。 实现Channel进程间通信能力。 4、Platform层/mojo/public/cpp/platform目录。 handle 为PlatformHandle。 系统层面的实现主要是对Socket文件描述的包装。
下面我们具体分析一下每一层handle的实现。
ipcz 层 IpczHandle实现
third_party/ipcz/src/ipcz/api_object.h
class APIObject : public RefCounted {public:enum ObjectType {kNode,kPortal,kBox,kTransport,kParcel,};static APIObject* FromHandle(IpczHandle handle) {return reinterpret_castAPIObject(static_castuintptr_t(handle));}// Takes ownership of an APIObject from an existing handle.static RefAPIObject TakeFromHandle(IpczHandle handle) {return AdoptRef(reinterpret_castAPIObject(static_castuintptr_t(handle)));}// Returns an IpczHandle which can be used to reference this object. The// reference is not owned by the caller.IpczHandle handle() const { return reinterpret_castuintptr_t(this); }// Releases ownership of a RefAPIObject to produce a new IpczHandle which// implicilty owns the released reference.static IpczHandle ReleaseAsHandle(RefAPIObject object) {return static_castIpczHandle(reinterpret_castuintptr_t(object.release()));}
……
}ipcz层对应的对象基类为APIObjectAPIObject 提供四个方法FromHandle() 和 TakeFromHandle() 方法用于将IpczHandle() 转化为具体对象。handle() 和 ReleaseAsHandle() 方法用于将对象转成IpczHandle句柄。这里我们还可以看到系统里有5种类型的APIObject分别是
kNode 代表IPCZ Node节点对象kPortal 代表ipcz Portal端口对象kBox 用于其他可传输的ipcz对象kTransport 代表ipcz Transport传输点对象kParcel 代表ipcz Parcel(消息)对象
ipcz driver 层 IpczDriverHandle实现
typedef uintptr_t IpczDriverHandle;mojo/core/ipcz_driver/object.h
// Common base class for objects managed by Mojos ipcz driver.
class MOJO_SYSTEM_IMPL_EXPORT ObjectBase: public base::RefCountedThreadSafeObjectBase {public:REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();enum Type : uint32t {// An ipcz transport endpoint.kTransport,// A wrapped shared memory region.kSharedBuffer,// An active mapping for a shared memory region. These objects are not// serializable and cannot be transmitted over a Transport.kSharedBufferMapping,// A PlatformHandle which can be transmitted as-is by the platforms Channel// implementation, out-of-band from message data. This is the only type of// driver object which can be emitted by the drivers Serialize(), and its// the only type accepted by its Transmit(). This type is unused on Windows,// where all platform handles are encoded as inline message data during// serialization.kTransmissiblePlatformHandle,// A PlatformHandle which may or may not be transmissible by the platforms// Channel implementation, but which can at least be transformed into// something transmissible during serialization.kWrappedPlatformHandle,// A DataPipe instance used to emulate Mojo data pipes over ipcz portals.kDataPipe,// A MojoTrap instance used to emulate a Mojo trap. These objects are not// serializable and cannot be transmitted over a Transport.kMojoTrap,// An Invitation instance used to emulate Mojo process invitations. These// objects are not serializable and cannot be transmitted over a Transport.kInvitation,};explicit ObjectBase(Type type);Type type() const { return type; }IpczDriverHandle handle() const {return reinterpret_castIpczDriverHandle(this);}static ObjectBase* FromHandle(IpczDriverHandle handle) {return reinterpret_castObjectBase*(handle);}static IpczDriverHandle ReleaseAsHandle(scoped_refptrObjectBase object) {return reinterpret_castIpczDriverHandle(object.release());}static scoped_refptrObjectBase TakeFromHandle(IpczDriverHandle handle) {scoped_refptrObjectBase object(FromHandle(handle));if (object) {// Were inheriting a ref previously owned by handle, so drop the extra// ref we just added.object-Release();}return object;}……
// Computes the number of bytes and platform handles required to serialize// this object for transmission through transmitter. Returns false if the// object cannot be serialized or transmitted as such.virtual bool GetSerializedDimensions(Transport transmitter,size_t num_bytes,size_t num_handles);// Attempts to serialize this object into data and handles which are// already sufficiently sized according to GetSerializedDimensions(). Returns// false if serialization fails.virtual bool Serialize(Transport transmitter,base::spanuint8_t data,base::spanPlatformHandle handles);ipcz driver层对应的对象基类为ObjectBaseObjectBase 提供的方法包括 type方法返回对象的类型FromHandle() 和 TakeFromHandle() 方法用于将IpczHandle() 转化为具体对象。handle() 和 ReleaseAsHandle() 方法用于将对象转成IpczHandle句柄。GetSerializedDimensions方法用来序列化过程中返回需要的内存空间和hanlde空间。 Serialize函数用于跨进程序列化传输。
这里我们还可以看到系统里有8种类型的ObjectBase分别是
kTransport 代表传输点对象kSharedBuffer 代表共享内存端口对象kSharedBufferMapping 映射后的共享内存对象kTransmissiblePlatformHandle 可传输的PlatformHandle对象kWrappedPlatformHandle 包装的PlatformHandle对象kDataPipe 数据管道kMojoTrap Trap监听对象kInvitation 链接邀请对象。
Mojo层 MojoHandle实现
typedef uintptr_t MojoHandle;
mojo层名没有对应的对象。可以和ipcz driver handle 和 ipcz handle强转。
Platform层 PlatformHandle实现
class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {public:enum class Type {kNone,
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_FUCHSIA)kHandle,
#elif BUILDFLAG(IS_APPLE)kMachSend,kMachReceive,
#endif
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(ISFUCHSIA)kFd,
#endif};private:Type type Type::kNone;#if BUILDFLAG(ISWIN)base::win::ScopedHandle handle;
#elif BUILDFLAG(ISFUCHSIA)zx::handle handle;
#elif BUILDFLAG(IS_APPLE)base::mac::ScopedMachSendRight machsend;base::mac::ScopedMachReceiveRight machreceive;
#endif#if BUILDFLAG(IS_POSIX) || BUILDFLAG(ISFUCHSIA)base::ScopedFD fd;
#endif
};对于linux系统 type为kFd fd_变量保存文件描述符。
- 上一篇: 网站开发与设计这么样软件开发平台协议
- 下一篇: 网站开发与推广就业作风建设年网站
相关文章
-
网站开发与设计这么样软件开发平台协议
网站开发与设计这么样软件开发平台协议
- 技术栈
- 2026年03月21日
-
网站开发与设计培训的就业前景石家庄网站优化多少钱
网站开发与设计培训的就业前景石家庄网站优化多少钱
- 技术栈
- 2026年03月21日
-
网站开发与软件销售如何进行网站制作
网站开发与软件销售如何进行网站制作
- 技术栈
- 2026年03月21日
-
网站开发与推广就业作风建设年网站
网站开发与推广就业作风建设年网站
- 技术栈
- 2026年03月21日
-
网站开发与维护费用多用户商城网站建设公司
网站开发与维护费用多用户商城网站建设公司
- 技术栈
- 2026年03月21日
-
网站开发与维护岗位说明书网站开发需要掌握的哪些开发软件
网站开发与维护岗位说明书网站开发需要掌握的哪些开发软件
- 技术栈
- 2026年03月21日
