flipperzero-zig/lib/flipperzero/atomic.zig

25 lines
717 B
Zig
Raw Normal View History

2024-08-22 02:27:21 +00:00
const flipperzero = @import("flipperzero.zig");
const c = flipperzero.c;
pub fn FuriMessageQueue(comptime T: type) type {
return extern struct {
const Self = @This();
pub fn create(msg_count: u32) *Self {
return @ptrCast(c.furi_message_queue_alloc(msg_count, @sizeOf(T)));
}
pub fn destroy(self: *Self) void {
c.furi_message_queue_free(self);
}
pub fn get(self: *Self, msg_ptr: *T, timeout: u32) void {
_ = c.furi_message_queue_get(self, msg_ptr, timeout);
}
pub fn put(self: *Self, msg_ptr: *const T, timeout: u32) void {
_ = c.furi_message_queue_put(self, msg_ptr, timeout);
}
};
}