Skip to content

Commit 33e3326

Browse files
author
Lucas Paixão
committed
Possibility to change the stack size
1 parent fcba072 commit 33e3326

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ pub fn uring_builder() -> io_uring::Builder {
164164
#[derive(Clone)]
165165
pub struct Builder {
166166
entries: u32,
167-
threads: usize,
167+
worker_threads: usize,
168+
thread_stack_size: usize,
168169
urb: io_uring::Builder,
169170
}
170171

@@ -177,7 +178,8 @@ pub struct Builder {
177178
pub fn builder() -> Builder {
178179
Builder {
179180
entries: 256,
180-
threads: std::thread::available_parallelism().unwrap().get(),
181+
worker_threads: std::thread::available_parallelism().unwrap().get(),
182+
thread_stack_size: 20971520,
181183
urb: io_uring::IoUring::builder(),
182184
}
183185
}
@@ -205,7 +207,13 @@ impl Builder {
205207

206208
/// Replaces the default number of worker threads
207209
pub fn worker_threads(&mut self, num: usize) -> &mut Self {
208-
self.threads = num;
210+
self.worker_threads = num;
211+
self
212+
}
213+
214+
/// Replaces the default number of worker threads stack size
215+
pub fn thread_stack_size(&mut self, num: usize) -> &mut Self {
216+
self.worker_threads = num;
209217
self
210218
}
211219

src/runtime/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ impl Runtime {
120120
let on_thread_start = runtime.create_on_thread_start_callback();
121121

122122
let rt = tokio::runtime::Builder::new_multi_thread()
123-
.worker_threads(builder.threads)
123+
.worker_threads(builder.worker_threads)
124+
.thread_stack_size(builder.thread_stack_size)
124125
.on_thread_start(on_thread_start)
125126
.on_thread_park(Runtime::on_thread_park)
126127
.enable_all()
@@ -191,7 +192,7 @@ impl Runtime {
191192
self.local.spawn_local(Runtime::drive_uring_wakes(
192193
self.contexts.clone(),
193194
self.signal.clone(),
194-
self.builder.threads,
195+
self.builder.worker_threads,
195196
));
196197
}
197198

0 commit comments

Comments
 (0)