示例#1
0
 async def write(self, dest: Pointer, data: bytes) -> None:
     if dest.size() != len(data):
         raise Exception("mismatched pointer size", dest.size(),
                         "and data size", len(data))
     src = await self.local.ram.ptr(data)
     dest_span = to_span(dest)
     await self.do_write(dest_span, src)
示例#2
0
 async def do_write(self, dest: Pointer, src: Pointer[bytes], i=0) -> None:
     if dest.size() == 0:
         return
     written, rest = await self.local.write(src)
     dest, dest_rest = dest.split(written.size())
     if dest_rest.size() != 0:
         raise NotImplementedError("partial write, oops, not supported yet")
     await self.remote.recv(dest, MSG.WAITALL)
示例#3
0
 async def read(self, src: Pointer) -> bytes:
     dest = await self.local.ram.malloc(bytes, src.size())
     src_span = to_span(src)
     return await self.do_read(dest, src_span)
示例#4
0
def to_span(ptr: Pointer) -> Pointer:
    "Wraps the pointer's allocation in SpanAllocation so it can be split freely"
    return Pointer(ptr.mapping, ptr.transport, ptr.serializer,
                   SpanAllocation(ptr.allocation, 0, ptr.allocation.size()),
                   ptr.typ)