saving
This commit is contained in:
parent
ffc84ce44c
commit
fc8165eb83
|
|
@ -14,13 +14,11 @@ pub const ConcurrentQueueError = error{
|
||||||
QueueIsFull,
|
QueueIsFull,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn ConcurrentQueueU(comptime T: type) type {
|
pub fn ConcurrentQueue(comptime T: type) type {
|
||||||
return ConcurrentQueueUnmanagedAdvanced(T, .{});
|
return ConcurrentQueueAdvanced(T, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ConcurrentQueueAssert(comptime T: type) type {
|
pub const ConcurrentQueueU = ConcurrentQueue;
|
||||||
return ConcurrentQueueUnmanagedAdvanced(T, .{ .allowAsserts = true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// lock-free concurrent queue, fixed capacity,
|
// lock-free concurrent queue, fixed capacity,
|
||||||
// will never resize.
|
// will never resize.
|
||||||
|
|
@ -33,7 +31,7 @@ pub const ConcurrentStatus = packed struct(usize) {
|
||||||
generation: u63 = 0,
|
generation: u63 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn ConcurrentQueueUnmanagedAdvanced(comptime T: type, comptime opts: struct {
|
pub fn ConcurrentQueueAdvanced(comptime T: type, comptime opts: struct {
|
||||||
allowAsserts: bool = false,
|
allowAsserts: bool = false,
|
||||||
debug: bool = false,
|
debug: bool = false,
|
||||||
}) type {
|
}) type {
|
||||||
|
|
@ -142,7 +140,7 @@ test "concurrent queue basic correctness test" {
|
||||||
|
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
|
|
||||||
var y = try ConcurrentQueueUnmanagedAdvanced(Info, .{ .allowAsserts = true, .debug = true }).initCapacity(allocator, 420);
|
var y = try ConcurrentQueueAdvanced(Info, .{ .allowAsserts = true, .debug = true }).initCapacity(allocator, 420);
|
||||||
defer y.deinit(allocator);
|
defer y.deinit(allocator);
|
||||||
|
|
||||||
try y.push(.{});
|
try y.push(.{});
|
||||||
|
|
@ -158,7 +156,7 @@ test "concurrent queue basic correctness test" {
|
||||||
|
|
||||||
try utils.assertf(y.count() == 0, "expected there to be {d} elements in queue, we saw {d}", .{ 0, y.count() });
|
try utils.assertf(y.count() == 0, "expected there to be {d} elements in queue, we saw {d}", .{ 0, y.count() });
|
||||||
|
|
||||||
var x = try ConcurrentQueueU(Info).initCapacity(allocator, 12);
|
var x = try ConcurrentQueue(Info).initCapacity(allocator, 12);
|
||||||
defer x.deinit(allocator);
|
defer x.deinit(allocator);
|
||||||
|
|
||||||
try x.push(.{ .x = 0 });
|
try x.push(.{ .x = 0 });
|
||||||
|
|
@ -189,7 +187,7 @@ test "concurrent queue multiple producer single consumer" {
|
||||||
arb: [4096]u8 = undefined,
|
arb: [4096]u8 = undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const QueueType = ConcurrentQueueUnmanagedAdvanced(Payload, .{ .debug = false, .allowAsserts = true });
|
const QueueType = ConcurrentQueueAdvanced(Payload, .{ .debug = false, .allowAsserts = true });
|
||||||
|
|
||||||
const Wrap = struct {
|
const Wrap = struct {
|
||||||
pub fn threadFunc(queueRef: *QueueType, id: i64, exitSignal: *Atomic(bool), pushedCountResults: *Atomic(i64)) void {
|
pub fn threadFunc(queueRef: *QueueType, id: i64, exitSignal: *Atomic(bool), pushedCountResults: *Atomic(i64)) void {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue