Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upInitial implementation of `threadpool::Builder`. #83
Conversation
frewsxcv
reviewed
Aug 12, 2017
| self | ||
| } | ||
|
|
||
| pub fn stack_size(mut self, size: usize) -> Builder { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I would call it |
This comment has been minimized.
This comment has been minimized.
|
I chose Builder to match the one in the standard library https://doc.rust-lang.org/std/thread/struct.Builder.html |
This comment has been minimized.
This comment has been minimized.
|
Good point. I was thinking about the
let pool = Builder. ... set_pool_name("first name");
pool.execute( ... ); // Worker with the first name
pool.rename("some new name");
pool.execute( ... ); // once this job is scheduled the worker will rename itselfI think, renaming a thread currently requires to spawn a new thread with the stable branch. |
frewsxcv
added some commits
Aug 19, 2017
mjkillough
reviewed
Aug 22, 2017
| /// The three configuration options available: | ||
| /// | ||
| /// * `num_threads`: maximum number of threads that will be alive at any given moment by the built | ||
| /// `ThreadPool` |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Interesting ideas! I'm not sure what distinction you're making between the 'worker' and 'thread' names here. Are these ideas for this PR or could they be done in a follow-up PR? |
dns2utf8
referenced this pull request
Sep 1, 2017
Closed
First implementation of Thread::set_name(&str) #44258
This comment has been minimized.
This comment has been minimized.
|
The renaming can be implemented later. I think it would only require the If I recall correctly I made the distinction to |
dns2utf8
reviewed
Sep 1, 2017
|
I would prefer the constructing function to be reusable/non-consuming. In case somebody would like to create multiple pools with a similar configuration. |
| /// .thread_stack_size(4_000_000) | ||
| /// .finish(); | ||
| /// ``` | ||
| pub fn finish(self) -> ThreadPool { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
frewsxcv
added some commits
Sep 4, 2017
This comment has been minimized.
This comment has been minimized.
fair enough. added see anything else? |
dns2utf8
reviewed
Sep 4, 2017
| /// .thread_stack_size(4_000_000) | ||
| /// .build(); | ||
| /// ``` | ||
| pub fn build(self) -> ThreadPool { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
frewsxcv
Sep 4, 2017
•
Author
Collaborator
that would cause unnecessary allocations. if the user needs to build another threadpool Builder (most do not), they can just call clone on the Builder.
This comment has been minimized.
This comment has been minimized.
|
After thinking about it a bit more, leaving the I don't have a strong opinion on Apart from that: |
This comment has been minimized.
This comment has been minimized.
|
this is what the code looks like if we changed diff --git a/src/lib.rs b/src/lib.rs
index 6a78abf..a889008 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -278,13 +278,13 @@ impl Builder {
/// .thread_stack_size(4_000_000)
/// .build();
/// ```
- pub fn build(self) -> ThreadPool {
+ pub fn build(&self) -> ThreadPool {
let (tx, rx) = channel::<Thunk<'static>>();
let num_threads = self.num_threads.unwrap_or_else(num_cpus::get);
let shared_data = Arc::new(ThreadPoolSharedData {
- name: self.thread_name,
+ name: self.thread_name.clone(),
job_receiver: Mutex::new(rx),
empty_condvar: Condvar::new(),
empty_trigger: Mutex::new(()),this means that if someone did |
This comment has been minimized.
This comment has been minimized.
|
Ah, good point. I did not think of that. Merge? |
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
frewsxcv
referenced this pull request
Sep 4, 2017
Open
Migrating a repository between owners causes bors to stop working #291
frewsxcv
closed this
Sep 4, 2017
frewsxcv
reopened this
Sep 4, 2017
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
This comment has been minimized.
This comment has been minimized.
|
bors ping |
This comment has been minimized.
This comment has been minimized.
|
bors r+ Can I talk to bors too? |
This comment has been minimized.
This comment has been minimized.
|
You should be able to, but it's not working. Probably related to moving this repo from @frewsxcv's account to the organization. |
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
bors bot
added a commit
that referenced
this pull request
Sep 5, 2017
This comment has been minimized.
This comment has been minimized.
Timed out |
This comment has been minimized.
This comment has been minimized.
|
bors retry |
This comment has been minimized.
This comment has been minimized.
|
Has AppVeyor been turned on yet? |
This comment has been minimized.
This comment has been minimized.
|
bors r+ |
bors bot
added a commit
that referenced
this pull request
Sep 6, 2017
This comment has been minimized.
This comment has been minimized.
|
@notriddle That was it. Appveyor didn't track the rename so it was not longer enabled. Wonder if there's a better way to handle this, maybe bors should add a comment |
This comment has been minimized.
This comment has been minimized.
|
I know what bors needs to do to handle the rename, roughly speaking. And I can't fix AppVeyor. |
frewsxcv commentedAug 12, 2017
•
edited
Related to #77.