diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-02-20 00:05:38 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-02-20 00:05:38 -0500 |
| commit | 3d58d7232ab6d1fd54523182beb99c31512bc4b9 (patch) | |
| tree | 23303c1ac09a121c59fb075747e74fffcb838f83 /std | |
| parent | af10b0fec213172b0403abfd8ff6e53c88f8c3c6 (diff) | |
| download | zig-3d58d7232ab6d1fd54523182beb99c31512bc4b9.tar.gz zig-3d58d7232ab6d1fd54523182beb99c31512bc4b9.zip | |
parse async fn calls and cancel expressions
Diffstat (limited to 'std')
| -rw-r--r-- | std/mem.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/std/mem.zig b/std/mem.zig index 07521bfcb8..1dfef86a8f 100644 --- a/std/mem.zig +++ b/std/mem.zig @@ -116,6 +116,22 @@ pub const Allocator = struct { const non_const_ptr = @intToPtr(&u8, @ptrToInt(bytes.ptr)); self.freeFn(self, non_const_ptr[0..bytes.len]); } + + pub const AsyncAllocator = struct { + allocator: &Allocator, + + fn alloc(self: &const AsyncAllocator, byte_count: usize, alignment: u29) Error![]u8 { + return self.allocator.allocFn(self.allocator, byte_count, alignment); + } + + fn free(self: &const AsyncAllocator, old_mem: []u8) { + return self.allocator.freeFn(self.allocator, old_mem); + } + }; + + fn toAsync(self: &Allocator) AsyncAllocator { + return AsyncAllocator { .allocator = self }; + } }; /// Copy all of source into dest at position 0. |
