summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/builder.rs
AgeCommit message (Collapse)Author
2020-10-16Fix doc typo (#2967)Alice Ryhl
2020-10-13rt: update docs for `0.3` changes (#2956)Lucio Franco
This PR updates the runtime module docs to the changes made in `0.3` release of tokio. Closes #2720
2020-10-13rt: switch `enter` to an RAII guard (#2954)Carl Lerche
2020-10-12rt: simplify rt-* features (#2949)Taiki Endo
tokio: merge rt-core and rt-util as rt rename rt-threaded to rt-multi-thread tokio-util: rename rt-core to rt Closes #2942
2020-10-12rt: `worker_threads` must be non-zero (#2947)Lucio Franco
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-10-13net: merge tcp, udp, uds features to net feature (#2943)Taiki Endo
2020-10-12rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876)Lucio Franco
Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Carl Lerche <me@carllerche.com>
2020-09-24chore: remove internal io-driver cargo feature (#2881)Ivan Petkov
2020-09-24rt: Allow concurrent `Shell:block_on` calls (#2868)Lucio Franco
2020-09-23rt: Allow concurrent `block_on`'s with basic_scheduler (#2804)Lucio Franco
2020-09-22signal: move driver to runtime thread (#2835)Ivan Petkov
Refactors the signal infrastructure to move the driver to the runtime thread. This follows the model put forth by the I/O driver and time driver.
2020-09-23ci: deny warnings on '--cfg tokio_unstable' tests (#2859)Taiki Endo
2020-09-07runtime: add custom keep_alive functionality (#2809)Blas Rodriguez Irizar
Co-authored-by: Eliza Weisman <eliza@buoyant.io> Fixes: #2585
2020-08-27rt: Refactor `Runtime::block_on` to take `&self` (#2782)Lucio Franco
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-08-24runtime: add thread_name_fn method to runtime::Builder (#1921)wspsxing
Fixes: #1907
2020-05-30docs: replace method links with intra-links (#2540)xliiv
2020-04-28rt: fix default thread number logic (#2457)Carl Lerche
Previously, the function picking the default number of threads for the threaded runtime did not factor in `max_threads`. Instead, it only used the value returned by `num_cpus`. However, if `num_cpus` returns a value greater than `max_threads`, then the function would panic. This patch fixes the function by limiting the default number of threads by `max_threads`. Fixes #2452
2020-04-24runtime: improve runtime and handle doc (#2440)Alice Ryhl
Refs: #2437
2020-03-05rt: cleanup and simplify scheduler (scheduler v2.5) (#2273)Carl Lerche
A refactor of the scheduler internals focusing on simplifying and reducing unsafety. There are no fundamental logic changes. * The state transitions of the core task component are refined and reduced. * `basic_scheduler` has most unsafety removed. * `local_set` has most unsafety removed. * `threaded_scheduler` limits most unsafety to its queue implementation.
2020-02-27runtime: add threaded_scheduler to examples (#2277)Alice Ryhl
It can be pretty confusing when the core_threads example does not call threaded_scheduler, when actually building such a runtime results in panics if you try to spawn something on it: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=866b3af344b0d6aad170ac9cbc9d57ed
2020-02-13rt: lazily detect number of CPUs (#2238)Luca Bruno
This tweaks the runtime builder default to defer and lazily auto-detect the number of CPUs. This is done in order to avoid performing useless operations which may be expensive on some platforms (e.g. Linux, where it is coupled to CPU frequency probing). Ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d5905dc14a87805a59f3c5bf70173aac2bb18f8
2020-01-24docs: use third form in API docs (#2027)Oleg Nosov
2020-01-07rt: cleanup runtime::context (#2063)Carl Lerche
Tweak context to remove more fns and usage of `Option`. Remove `ThreadContext` struct as it is reduced to just `Handle`. Avoid passing around individual driver handles and instead limit to the `runtime::Handle` struct.
2019-12-18Improve runtime threading options docsDouman
2019-12-18rt: add configuration for core threads and max threads (#1977)Douman
`num_threads` is deprecated. Instead, `core_threads` and `max_threads` are introduced. `core_threads` specifies the number of "always on" threads used for the async task executor and `max_threads` specifies the maximum number of threads that the runtime may spawn.
2019-12-13chore: remove benches and fix/work around clippy lints (#1952)Artem Vorotnikov
2019-11-29docs: Mention features for basic_scheduler, threaded_scheduler (#1858)Ömer Sinan Ağacan
Fixes #1829
2019-11-27doc: fix `runtime::Builder` example (#1841)Oleg Nosov
2019-11-21runtime: cleanup and add config options (#1807)Carl Lerche
* runtime: cleanup and add config options This patch finishes the cleanup as part of the transition to Tokio 0.2. A number of changes were made to take advantage of having all Tokio types in a single crate. Also, fixes using Tokio types from `spawn_blocking`. * Many threads, one resource driver Previously, in the threaded scheduler, a resource driver (mio::Poll / timer combo) was created per thread. This was more or less fine, except it required balancing across the available drivers. When using a resource driver from **outside** of the thread pool, balancing is tricky. The change was original done to avoid having a dedicated driver thread. Now, instead of creating many resource drivers, a single resource driver is used. Each scheduler thread will attempt to "lock" the resource driver before parking on it. If the resource driver is already locked, the thread uses a condition variable to park. Contention should remain low as, under load, the scheduler avoids using the drivers. * Add configuration options to enable I/O / time New configuration options are added to `runtime::Builder` to allow enabling I/O and time drivers on a runtime instance basis. This is useful when wanting to create lightweight runtime instances to execute compute only tasks. * Bug fixes The condition variable parker is updated to the same algorithm used in `std`. This is motivated by some potential deadlock cases discovered by `loom`. The basic scheduler is fixed to fairly schedule tasks. `push_front` was accidentally used instead of `push_back`. I/O, time, and spawning now work from within `spawn_blocking` closures. * Misc cleanup The threaded scheduler is no longer generic over `P :Park`. Instead, it is hard coded to a specific parker. Tests, including loom tests, are updated to use `Runtime` directly. This provides greater coverage. The `blocking` module is moved back into `runtime` as all usage is within `runtime` itself.
2019-11-18chore: refine feature flags (#1785)Carl Lerche
Removes dependencies between Tokio feature flags. For example, `process` should not depend on `sync` simply because it uses the `mpsc` channel. Instead, feature flags represent **public** APIs that become available with the feature enabled. When the feature is not enabled, the functionality is removed. If another Tokio component requires the functionality, it is stays as `pub(crate)`. The threaded scheduler is now exposed under `rt-threaded`. This feature flag only enables the threaded scheduler and does not include I/O, networking, or time. Those features must be explictly enabled. A `full` feature flag is added that enables all features. `stdin`, `stdout`, `stderr` are exposed under `io-std`. Macros are used to scope code by feature flag.
2019-11-16runtime: rename current_thread -> basic_scheduler (#1769)Carl Lerche
It no longer supports executing !Send futures. The use case for It is wanting a “light” runtime. There will be “local” task execution using a different strategy coming later. This patch also renames `thread_pool` -> `threaded_scheduler`, but only in public APIs for now.
2019-11-12reorganize modules (#1766)Carl Lerche
This patch started as an effort to make `time::Timer` private. However, in an effort to get the build compiling again, more and more changes were made. This probably should have been broken up, but here we are. I will attempt to summarize the changes here. * Feature flags are reorganized to make clearer. `net-driver` becomes `io-driver`. `rt-current-thread` becomes `rt-core`. * The `Runtime` can be created without any executor. This replaces `enter`. It also allows creating I/O / time drivers that are standalone. * `tokio::timer` is renamed to `tokio::time`. This brings it in line with `std`. * `tokio::timer::Timer` is renamed to `Driver` and made private. * The `clock` module is removed. Instead, an `Instant` type is provided. This type defaults to calling `std::time::Instant`. A `test-util` feature flag can be used to enable hooking into time. * The `blocking` module is moved to the top level and is cleaned up. * The `task` module is moved to the top level. * The thread-pool's in-place blocking implementation is cleaned up. * `runtime::Spawner` is renamed to `runtime::Handle` and can be used to "enter" a runtime context.
2019-11-06time: rename `tokio::timer` -> `tokio::time` (#1745)Carl Lerche
2019-11-06runtime: misc pool cleanup (#1743)Carl Lerche
- Remove builders for internal types - Avoid duplicating the blocking pool when using the concurrent scheduler. - misc smaller cleanup
2019-11-05runtime: combine `executor` and `runtime` mods (#1734)Carl Lerche
Now, all types are under `runtime`. `executor::util` is moved to a top level `util` module.
2019-11-04chore: unify all mocked `loom` files (#1732)Carl Lerche
When the crates were merged, each component kept its own `loom` file containing mocked types it needed. This patch unifies them all in one location.
2019-11-04executor: switch some APIs to crate private. (#1731)Carl Lerche
* switch `enter` to crate private * make executor types pub(crate)
2019-11-01runtime: merge multi & single threaded runtimes (#1716)Carl Lerche
Simplify Tokio's runtime construct by combining both Runtime variants into a single type. The execution style can be controlled by a configuration setting on `Builder`. The implication of this change is that there is no longer any way to spawn `!Send` futures. This, however, is a temporary limitation. A different strategy will be employed for supporting `!Send` futures. Included in this patch is a rework of `task::JoinHandle` to support using this type from both the thread-pool and current-thread executors.