# Halloween Challenge: Cursed Zig

**URL:** <https://ziggit.dev/t/halloween-challenge-cursed-zig/18153>\
**Category:** Brainstorming\
**Created:** [October 30, 2026, 3:08pm UTC](https://ziggit.dev/t/halloween-challenge-cursed-zig/18153 "2026-10-30T15:08:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tholmes](https://ziggit.dev/user_avatar/ziggit.dev/tholmes/32/5641_2.png) [@tholmes](https://ziggit.dev/u/tholmes)\
**Post date:** [October 30, 2026, 3:36pm UTC](https://ziggit.dev/t/halloween-challenge-cursed-zig/18153/2 "2026-10-30T15:36:12Z")

</div>

I’ve got one for you that I literally wrote earlier today:

```zig
/// Attempt to start a concurrent task, eventually erroring out if we can't start the task
/// after a stupidly high number of retries.
fn start_task(
	io: std.Io, group: *std.Io.Group,
	task: anytype, args: std.meta.ArgsTuple(@TypeOf(task))
) error{ConcurrencyUnavailable}!void {
	const MAX_RETRIES = @as(usize, 1) << 12;
	var retry_count: usize = 0;

	// Convoluted way to add a task.
	// We optimistically assume concurrency will only be unavailable if we have too
	// many tasks going at once, so if it's unavailable we await the group, then try
	// again.
	// This is probably maximally cursed Zig code.
	while(if(group.concurrent(io, task, args)) |_| false else |_| true) : (retry_count += 1) {
		if(retry_count >= MAX_RETRIES) return error.ConcurrencyUnavailable;
		group.await(io) catch std.log.err("Tasks were somehow cancelled!", .{});
	}{}
}

```

---

_[View the full topic](https://ziggit.dev/t/halloween-challenge-cursed-zig/18153)._
