Compare commits
2 commits
master
...
zig-0.15.0
Author | SHA1 | Date | |
---|---|---|---|
6fb364d64b | |||
0e3806ab98 |
4 changed files with 20 additions and 11 deletions
|
@ -1 +1 @@
|
||||||
0.14.1
|
0.15.0-dev.703+597dd328e
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
.hash = "fuzzig-0.1.1-AAAAALNIAQBmbHr-MPalGuR393Vem2pTQXI7_LXeNJgX",
|
.hash = "fuzzig-0.1.1-AAAAALNIAQBmbHr-MPalGuR393Vem2pTQXI7_LXeNJgX",
|
||||||
},
|
},
|
||||||
.vaxis = .{
|
.vaxis = .{
|
||||||
.url = "https://github.com/neurocyte/libvaxis/archive/6137cb4c44a7350996f0946a069739e5075d1f23.tar.gz",
|
.url = "https://github.com/neurocyte/libvaxis/archive/64a29f4f91292bc79dc9afb9a254cbdfb35e29a6.tar.gz",
|
||||||
.hash = "vaxis-0.1.0-BWNV_HwOCQCw5wTV63hQGSc1QJzsNcytH6sGf1GBc0hP",
|
.hash = "vaxis-0.1.0-BWNV_KEOCQCzedUR1prWhPUcgsRmw8f-r5JBc3s4DLJf",
|
||||||
},
|
},
|
||||||
.zeit = .{
|
.zeit = .{
|
||||||
.url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz",
|
.url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz",
|
||||||
|
|
|
@ -1222,6 +1222,7 @@ pub const LoadFromFileError = error{
|
||||||
LockViolation,
|
LockViolation,
|
||||||
ProcessNotFound,
|
ProcessNotFound,
|
||||||
Canceled,
|
Canceled,
|
||||||
|
PermissionDenied,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_from_file(
|
pub fn load_from_file(
|
||||||
|
@ -1327,6 +1328,8 @@ pub const StoreToFileError = error{
|
||||||
SystemResources,
|
SystemResources,
|
||||||
Unexpected,
|
Unexpected,
|
||||||
WouldBlock,
|
WouldBlock,
|
||||||
|
PermissionDenied,
|
||||||
|
MessageTooBig,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
||||||
|
|
22
src/log.zig
22
src/log.zig
|
@ -10,9 +10,14 @@ receiver: Receiver,
|
||||||
subscriber: ?tp.pid,
|
subscriber: ?tp.pid,
|
||||||
heap: [32 + 1024]u8,
|
heap: [32 + 1024]u8,
|
||||||
fba: std.heap.FixedBufferAllocator,
|
fba: std.heap.FixedBufferAllocator,
|
||||||
msg_store: MsgStoreT,
|
msg_store: MsgStore,
|
||||||
|
|
||||||
|
const MsgStore = std.DoublyLinkedList;
|
||||||
|
const MsgStoreEntry = struct {
|
||||||
|
data: []u8,
|
||||||
|
node: MsgStore.Node,
|
||||||
|
};
|
||||||
|
|
||||||
const MsgStoreT = std.DoublyLinkedList([]u8);
|
|
||||||
const Receiver = tp.Receiver(*Self);
|
const Receiver = tp.Receiver(*Self);
|
||||||
|
|
||||||
const StartArgs = struct {
|
const StartArgs = struct {
|
||||||
|
@ -38,7 +43,7 @@ fn init(args: StartArgs) !*Self {
|
||||||
.subscriber = null,
|
.subscriber = null,
|
||||||
.heap = undefined,
|
.heap = undefined,
|
||||||
.fba = std.heap.FixedBufferAllocator.init(&p.heap),
|
.fba = std.heap.FixedBufferAllocator.init(&p.heap),
|
||||||
.msg_store = MsgStoreT{},
|
.msg_store = MsgStore{},
|
||||||
};
|
};
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -55,17 +60,18 @@ fn log(msg: []const u8) void {
|
||||||
fn store(self: *Self, m: tp.message) void {
|
fn store(self: *Self, m: tp.message) void {
|
||||||
const allocator: std.mem.Allocator = self.fba.allocator();
|
const allocator: std.mem.Allocator = self.fba.allocator();
|
||||||
const buf: []u8 = allocator.alloc(u8, m.len()) catch return;
|
const buf: []u8 = allocator.alloc(u8, m.len()) catch return;
|
||||||
var node: *MsgStoreT.Node = allocator.create(MsgStoreT.Node) catch return;
|
var msg: *MsgStoreEntry = allocator.create(MsgStoreEntry) catch return;
|
||||||
node.data = buf;
|
msg.data = buf;
|
||||||
@memcpy(buf, m.buf);
|
@memcpy(buf, m.buf);
|
||||||
self.msg_store.append(node);
|
self.msg_store.append(&msg.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_send(self: *Self) void {
|
fn store_send(self: *Self) void {
|
||||||
var node = self.msg_store.first;
|
var node = self.msg_store.first;
|
||||||
if (self.subscriber) |sub| {
|
if (self.subscriber) |sub| {
|
||||||
while (node) |node_| {
|
while (node) |node_| {
|
||||||
sub.send_raw(tp.message{ .buf = node_.data }) catch return;
|
const msg: *MsgStoreEntry = @fieldParentPtr("node", node_);
|
||||||
|
sub.send_raw(tp.message{ .buf = msg.data }) catch return;
|
||||||
node = node_.next;
|
node = node_.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +79,7 @@ fn store_send(self: *Self) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_reset(self: *Self) void {
|
fn store_reset(self: *Self) void {
|
||||||
self.msg_store = MsgStoreT{};
|
self.msg_store = MsgStore{};
|
||||||
self.fba.reset();
|
self.fba.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue