Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more constructors #106

Merged
merged 1 commit into from
Mar 7, 2017
Merged

Add more constructors #106

merged 1 commit into from
Mar 7, 2017

Conversation

torkleyy
Copy link
Member

@torkleyy torkleyy commented Mar 6, 2017

  • Use the number of cpus as pool size
  • Allows sharing the thread pool

@torkleyy torkleyy mentioned this pull request Mar 6, 2017
@kvark
Copy link
Member

kvark commented Mar 6, 2017

Why don't you want to simply remove the constructor that accepts a number of threads? I don't see many consumers of this one, and they can work around by creating ThreadPool themselves.

@torkleyy
Copy link
Member Author

torkleyy commented Mar 6, 2017

As @nchash wrote

Maybe add a Planner::new, taking a usize and Planner::new_num_cpus. There are use cases where you don't need an Arc and you need to set the number of threads (for example to benchmark performance with and without multithreading).

And from the user's perspective it isn't obvious that the way you get a Planner with a set number of threads is call Planner::from_pool.

Additionally, doing it that way is non breaking and easier to understand what it does from the function name.

And there's not really a disadvantage of having one more function.

@kvark
Copy link
Member

kvark commented Mar 6, 2017

Well, I don't agree with @nchashch proposal here. I think new() should be dumb simple and good for everyone, so having no parameters is great.

There are use cases where you don't need an Arc and you need to set the number of threads (for example to benchmark performance with and without multithreading).

The non-multithreaded mod is a bigger task - #72 , we don't need to cater for it since we don't yet know how it is going to work.

And from the user's perspective it isn't obvious that the way you get a Planner with a set number of threads is call Planner::from_pool.

As I said, a regular user would not care. An advanced user would figure from_pool out.

Additionally, doing it that way is non breaking ...

Don't worry about breaking too much. We are on the verge of 0.8, which is fine to break API a little.

... and easier to understand what it does from the function name.

The easiest thing to understand is new() without parameters, and that's what I'm arguing for.

And there's not really a disadvantage of having one more function.

Sure thing, as long as you keep the most used case unencumbered. So, it's fine to have an extra with_num_threads constructor, but not fine to have usize parameter for new().

@torkleyy
Copy link
Member Author

torkleyy commented Mar 6, 2017

@kvark Good idea, did that

@kvark
Copy link
Member

kvark commented Mar 6, 2017

Thanks @torkleyy ! Last things - make CI happy and squash the commits please.

@kvark kvark merged commit c513916 into amethyst:master Mar 7, 2017
@torkleyy torkleyy deleted the more_constructors branch March 7, 2017 19:34
bors bot added a commit that referenced this pull request Aug 26, 2019
627: Update hashbrown requirement from 0.5.0 to 0.6.0 r=torkleyy a=dependabot-preview[bot]

Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
<details>
<summary>Changelog</summary>

*Sourced from [hashbrown's changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md).*

> ## [v0.6.0] - 2019-08-13
> 
> ### Fixed
> - Fixed AHash accidentally depending on `std`. ([#110](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/110))
> 
> ### Changed
> - The minimum Rust version has been bumped to 1.32 (due to `rand` dependency).
> 
> ## ~~[v0.5.1] - 2019-08-04~~
> 
> This release was _yanked_ due to a breaking change for users of `no-default-features`.
> 
> ### Added
> - The experimental and unsafe `RawTable` API is available under the "raw" feature. ([#108](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/108))
> - Added entry-like methods for `HashSet`. ([#98](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/98))
> 
> ### Changed
> - Changed the default hasher from FxHash to AHash. ([#97](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/97))
> - `hashbrown` is now fully `no_std` on recent Rust versions (1.36+). ([#96](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/96))
> 
> ### Fixed
> - We now avoid growing the table during insertions when it wasn't necessary. ([#106](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/106))
> - `RawOccupiedEntryMut` now properly implements `Send` and `Sync`. ([#100](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/100))
> - Relaxed `lazy_static` version. ([#92](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/92))
> 
> ## [v0.5.0] - 2019-06-12
> 
> ### Fixed
> - Resize with a more conservative amount of space after deletions. ([#86](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/86))
> 
> ### Changed
> - Exposed the Layout of the failed allocation in CollectionAllocErr::AllocErr. ([#89](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/89))
> 
> ## [v0.4.0] - 2019-05-30
> 
> ### Fixed
> - Fixed `Send` trait bounds on `IterMut` not matching the libstd one. ([#82](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/82))
> 
> ## [v0.3.1] - 2019-05-30
> 
> ### Fixed
> - Fixed incorrect use of slice in unsafe code. ([#80](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/80))
> 
> ## [v0.3.0] - 2019-04-23
> 
> ### Changed
> - Changed shrink_to to not panic if min_capacity < capacity. ([#67](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/67))
> 
> ### Fixed
> - Worked around emscripten bug emscripten-core/emscripten-fastcomp#258. ([#66](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/66))
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`0a62c3e`](rust-lang/hashbrown@0a62c3e) Version 0.6.0
- [`0c1209a`](rust-lang/hashbrown@0c1209a) Auto merge of [#110](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/110) - Amanieu:no_std_ci, r=Amanieu
- [`8ae33c9`](rust-lang/hashbrown@8ae33c9) Don't use cross for thumb target CI
- [`3239c2b`](rust-lang/hashbrown@3239c2b) Fix clippy warnings
- [`12c55b6`](rust-lang/hashbrown@12c55b6) Bump minimum Rust version to 1.32
- [`fb0a938`](rust-lang/hashbrown@fb0a938) Bump minimum ahash version to 0.2.11
- [`bacb169`](rust-lang/hashbrown@bacb169) Merge pull request [#111](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/111) from RalfJung/readme
- [`2921920`](rust-lang/hashbrown@2921920) when hashers with different design goals are compared, that should be noted
- [`aecb361`](rust-lang/hashbrown@aecb361) Check in CI that the crate builds on targets without libstd
- [`167eb54`](rust-lang/hashbrown@167eb54) Version 0.5.1
- Additional commits viewable in [compare view](rust-lang/hashbrown@v0.5.0...v0.6.0)
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>

631: Remove dependency on mopa crate r=torkleyy a=willglynn

`mopa::Any` is less necessary with changes to `std::any::Any`, and `specs` wasn't calling the `mopafy!()` macro for `Component` anyway.

## Checklist

* **n/a** I've added tests for all code changes and additions (where applicable)
* **n/a** I've added a demonstration of the new feature to one or more examples
* **n/a** I've updated the book to reflect my changes
* **n/a** Usage of new public items is shown in the API docs

Nothing in the `specs` repo except the `Component` definition and an associated generic type in a test refer to `Any`, and even then only in type bounds. No tests or examples are affected.

## API changes

This change breaks any code which specifically needs `trait Component: mopa::Any`, but as far as I can tell [that doesn't work now and hasn't since ±ever](#630 (comment)) since `specs` doesn't call the `mopafy!()` macro.

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Will Glynn <[email protected]>
xMAC94x pushed a commit to xMAC94x/specs that referenced this pull request Mar 10, 2021
106: Simplify build script r=torkleyy a=torkleyy



Co-authored-by: Thomas Schaller <[email protected]>
xMAC94x pushed a commit to xMAC94x/specs that referenced this pull request Mar 10, 2021
153: Update hashbrown requirement from 0.5.0 to 0.6.0 r=torkleyy a=dependabot-preview[bot]

Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
<details>
<summary>Changelog</summary>

*Sourced from [hashbrown's changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md).*

> ## [v0.6.0] - 2019-08-13
> 
> ### Fixed
> - Fixed AHash accidentally depending on `std`. ([amethyst#110](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/110))
> 
> ### Changed
> - The minimum Rust version has been bumped to 1.32 (due to `rand` dependency).
> 
> ## ~~[v0.5.1] - 2019-08-04~~
> 
> This release was _yanked_ due to a breaking change for users of `no-default-features`.
> 
> ### Added
> - The experimental and unsafe `RawTable` API is available under the "raw" feature. ([amethyst#108](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/108))
> - Added entry-like methods for `HashSet`. ([amethyst#98](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/98))
> 
> ### Changed
> - Changed the default hasher from FxHash to AHash. ([amethyst#97](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/97))
> - `hashbrown` is now fully `no_std` on recent Rust versions (1.36+). ([amethyst#96](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/96))
> 
> ### Fixed
> - We now avoid growing the table during insertions when it wasn't necessary. ([amethyst#106](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/106))
> - `RawOccupiedEntryMut` now properly implements `Send` and `Sync`. ([amethyst#100](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/100))
> - Relaxed `lazy_static` version. ([amethyst#92](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/92))
> 
> ## [v0.5.0] - 2019-06-12
> 
> ### Fixed
> - Resize with a more conservative amount of space after deletions. ([amethyst#86](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/86))
> 
> ### Changed
> - Exposed the Layout of the failed allocation in CollectionAllocErr::AllocErr. ([amethyst#89](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/89))
> 
> ## [v0.4.0] - 2019-05-30
> 
> ### Fixed
> - Fixed `Send` trait bounds on `IterMut` not matching the libstd one. ([amethyst#82](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/82))
> 
> ## [v0.3.1] - 2019-05-30
> 
> ### Fixed
> - Fixed incorrect use of slice in unsafe code. ([amethyst#80](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/80))
> 
> ## [v0.3.0] - 2019-04-23
> 
> ### Changed
> - Changed shrink_to to not panic if min_capacity < capacity. ([amethyst#67](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/67))
> 
> ### Fixed
> - Worked around emscripten bug emscripten-core/emscripten-fastcomp#258. ([amethyst#66](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/66))
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`0a62c3e`](rust-lang/hashbrown@0a62c3e) Version 0.6.0
- [`0c1209a`](rust-lang/hashbrown@0c1209a) Auto merge of [amethyst#110](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/110) - Amanieu:no_std_ci, r=Amanieu
- [`8ae33c9`](rust-lang/hashbrown@8ae33c9) Don't use cross for thumb target CI
- [`3239c2b`](rust-lang/hashbrown@3239c2b) Fix clippy warnings
- [`12c55b6`](rust-lang/hashbrown@12c55b6) Bump minimum Rust version to 1.32
- [`fb0a938`](rust-lang/hashbrown@fb0a938) Bump minimum ahash version to 0.2.11
- [`bacb169`](rust-lang/hashbrown@bacb169) Merge pull request [amethyst#111](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/111) from RalfJung/readme
- [`2921920`](rust-lang/hashbrown@2921920) when hashers with different design goals are compared, that should be noted
- [`aecb361`](rust-lang/hashbrown@aecb361) Check in CI that the crate builds on targets without libstd
- [`167eb54`](rust-lang/hashbrown@167eb54) Version 0.5.1
- Additional commits viewable in [compare view](rust-lang/hashbrown@v0.5.0...v0.6.0)
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants