Skip to content

Commit

Permalink
Fix threadpool not being initialized correctly with ThreadPool::new
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Sep 8, 2024
1 parent 1235f88 commit 7562cbf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Coming Soon
- Made internal::handle::handle function public for use in custom event loops.
- Made `error::AnyResult` public
- Disable keep-alive if only running with one thread
- Use nonblocking IO on supported platforms to allow shutting down the event loop from other threads
- Set default worker count to 16
- Create the Server with a builder
- Store config fields like host, default headers, etc. in a ServerConfig struct
Expand Down
10 changes: 4 additions & 6 deletions examples/tmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,10 @@ fn main() -> Result<(), Box<dyn Error>> {
// .status(Status::InternalServerError)?;

let threads = ctx.server.thread_pool.threads();
let thread = ctx.server.thread_pool.current_thread();
ctx.text(format!(
"Ok!\nThreads: {threads}\nCurrent Thread: {thread:?}"
))
.header((HeaderName::ContentType, "text/plain"))
.send()?;
let thread = ctx.server.thread_pool.current_thread().unwrap();
ctx.text(format!("Ok!\nThreads: {threads}\nCurrent Thread: {thread}"))
.header((HeaderName::ContentType, "text/plain"))
.send()?;

Ok(())
});
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl ThreadPool {
Self {
threads: AtomicUsize::new(size),
sender: Mutex::new(sender),
workers: Workers::new(),
workers,
receiver,
}
}
Expand Down

0 comments on commit 7562cbf

Please sign in to comment.