aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/thread_pool.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/thread_pool.zig b/src/thread_pool.zig
index 34bc45fc0..b3d25b015 100644
--- a/src/thread_pool.zig
+++ b/src/thread_pool.zig
@@ -8,10 +8,11 @@ const AsyncIO = @import("io");
const assert = std.debug.assert;
const Atomic = std.atomic.Atomic;
-
+pub const OnSpawnCallback = fn () void;
io: ?*AsyncIO = null,
sleep_on_idle_network_thread: bool = true,
-
+/// executed on the thread
+on_thread_spawn: ?OnSpawnCallback = null,
stack_size: u32,
max_threads: u32,
sync: Atomic(u32) = Atomic(u32).init(@bitCast(u32, Sync{})),
@@ -383,6 +384,10 @@ const Thread = struct {
var self = Thread{};
current = &self;
+ if (thread_pool.on_thread_spawn) |spawn| {
+ spawn();
+ }
+
thread_pool.register(&self);
defer thread_pool.unregister(&self);