The Zig Programming Language 0.8.1 Documentationexample of typical async/await usage: async.zig const std = @import("std"); const Allocator = std.mem.Allocator; pub fn main() void { _ = async amainWrap(); // Typically we would use an event std.process.exit(1); }; } fn amain() !void { const allocator = std.heap.page_allocator; var download_frame = async fetchUrl(allocator, "https://example.com/data.html"); var awaited_download_frame (!awaited_download_frame) { if (await download_frame) |r| allocator.free(r) else |_| {} }; var file_frame = async readFile(allocator, "something.txt"); var awaited_file_frame = false; errdefer0 码力 | 234 页 | 6.01 MB | 2 年前3
The Zig Programming Language 0.10.1 Documentationthe Zig Standard Library's testing allocator, std.testing.allocator, the default test runner will report any leaks that are found from using the testing allocator: test.zig const std = @import("std"); @import("std"); test "detect leak" { var list = std.ArrayList(u21).init(std.testing.allocator); // missing `defer list.deinit();` try list.append('+'); try std.testing.expect(list /home/ci/release-0.10.1/out/zig-x86_64-linux-musl-baseline/lib/zig/std/array_list. const new_memory = try self.allocator.reallocAtLeast(self.allocate); /home/ci/release-0.10.1/out/zig-x86_64-linux-musl-baseline/lib/zig/std/array_list0 码力 | 239 页 | 8.03 MB | 2 年前3
Practical memory pool based allocators for Modern C++parametrized with a user-provided allocator but they never actually use it directly ## Memory pools and C++ ## There is good news though ## Even when the user-provided allocator is not used, a related (“rebound”) they allocate for templateclass allocator { // ... template struct rebind { using other = allocator; }; // ... using pointer = T*; which adopts standard C++ allocator model without modifications but allocate from a memory pool under the hood ## I mplementation Components: 1. A memory pool 2. An allocator which allocates from a memory 0 码力 | 49 页 | 986.95 KB | 1 年前3
The Zig Programming Language 0.12.0 Documentationthe Zig Standard Library's testing allocator, std.testing.allocator, the default test runner will report any leaks that are found from using the testing allocator: testing_detect_leak.zig const std @import("std"); test "detect leak" { var list = std.ArrayList(u21).init(std.testing. allocator); } // missing `defer list.deinit();` try list.append('*'); try std.testing.expect(list r/_work/zig-bootstrap/out/host/lib/zig/std/array_list.zig:457:67: const new_memory = try self. allocator. alignedAlloc(T, alignment, new_ca); /home/ci/actions-runner/_work/zig-bootstrap/out/host/lib/zig/std/array_list0 码力 | 241 页 | 7.37 MB | 2 年前3
COMPOSABLE C++REALLY Composability is NOT about syntax! ## COMPOSABILITY IS JOB #1 "If you want to design an allocator, you gotta make composition the first thing in your design, the first concern." Getting composition the allocator that always returns nullptr ## FIRST: ZERO The first object to write is the one that does nothing, composably. • the logger that accepts an entry and produces no log • the allocator that one that does nothing, composably. • the logger that accepts an entry and produces no log • the allocator that always returns nullptr • the parser or validator that fails • the visitor that uses the identity0 码力 | 124 页 | 8.28 MB | 1 年前3
The Zig Programming Language 0.11.0 Documentationthe Zig Standard Library's testing allocator, std.testing.allocator, the default test runner will report any leaks that are found from using the testing allocator: testing_detect_leak.zig const std @import("std"); test "detect leak" { var list = std.ArrayList(u21).init(std.testing.allocator); // missing `defer list.deinit();` try list.append('*'); try std.testing.expect(list er/_work/zig-bootstrap/out/host/lib/zig/std/array_list.zig:403:67: const new_memory = try self.allocator.alignedAlloc(T, alignment, new_ca /home/ci/actions-runner/_work/zig-bootstrap/out/host/lib/zig/std/array_list0 码力 | 238 页 | 7.80 MB | 2 年前3
Using Modern C++ to Build XOffsetDatastructureadvantage in read and write operations. This performance is primarily attributed to our use of a custom allocator. |Containers|Read/Write(100 thousand times, ms)| |---|---| |std::*|68.0446| |boost::*|56.273| implementation technologies of XOffsetDatastructure are presented in this section. ### 5.1 Custom Allocator • Allocator • According to Wikipedia: 'In C++ computer programming, allocators are a component requests for allocation and deallocation of memory for a given container.' ### 5.1 Custom Allocator • Allocator • According to Wikipedia: 'In C++ computer programming, allocators are a component0 码力 | 111 页 | 3.03 MB | 1 年前3
The Zig Programming Language 0.5.0 DocumentationInteger Cast Pointer Cast Invalid Null Memory Choosing an Allocator Where are the bytes? Implementing an Allocator Heap Allocation Failure Recursion Lifetime and Ownership typical async/await usage: ### async.zig const std = @import("std"); const Allocator = std.mem.Allocator; pub fn main() void { _ = async amainWrap(); // Typically we would use an event process.exit(1); }; } fn amain() !void { const allocator = std.heap.direct_allocator; var download_frame = async fetchUrl(allocator, "https://example.com/var awaited_download_frame = false;0 码力 | 224 页 | 5.80 MB | 2 年前3
The Zig Programming Language 0.9.1 Documentationthe Zig Standard Library's testing allocator, std.testing.allocator, the default test runner will report any leaks that are found from using the testing allocator: test.zig const std = @import("std"); @import("std"); test "detect leak" { var list = std.ArrayList(u21).init(std.testing.allocator); // missing `defer list.deinit();` try list.append('='); try std.testing.expect(list /home/andy/tmp/zig/lib/std/array_list.zig:325:69: 0x20ce89 in std.array_list.Array const new_memory = try self.allocator.reallocAtLeast(self.allocate); /home/andy/tmp/zig/lib/std/array_list.zig:310:55: 0x20cc8e in std0 码力 | 234 页 | 7.90 MB | 2 年前3
The Zig Programming Language 0.6.0 Documentationexample of typical async/await usage: async.zig const std = @import("std"); const Allocator = std.mem.Allocator; pub fn main() void { _ = async amainWrap(); // Typically we would use an event std.process.exit(1); }; } fn amain() !void { const allocator = std.heap.page_allocator; var download_frame = async fetchUrl(allocator, "https://example.com/data/data/data/data/data/data/ ata/data/data/data/data/data/data/data/data/data/data/data/data/data/data/data/data/data defer allocator.free(download_text); std.debug.warn("download_text: {} ", {download_text}); std.debug.warn("file_text:0 码力 | 214 页 | 5.37 MB | 2 年前3
共 261 条
- 1
- 2
- 3
- 4
- 5
- 6
- 27
相关搜索词
AllocatorHeap Allocation FailureRecursionLifetime and OwnershipBuild SystemZig编程语言Zig标准库可选类型内存管理测试工具内存池分配器C++标准内存池生成内存池实例Zig LanguageStandard LibraryC InteropTestingcomposabilitycomposable typescomputationreturn typeshierarchiesZig语言标准库内联汇编构建系统交叉平台XOffsetDatastructureZero-Encoding & Zero-DecodingHigh-PerformanceSerialization LibraryMessage Size分配器接口堆分配失败递归所有权与生命周期内存分配所有权测试风格指南生命周期编译变量异常处理













