Skip to content

Commit 5495731

Browse files
committed
Remove prokio text from docs.
1 parent 4751bcc commit 5495731

File tree

2 files changed

+136
-134
lines changed

2 files changed

+136
-134
lines changed

src/lib.rs

Lines changed: 2 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
elided_lifetimes_in_paths
5353
)]
5454

55-
use std::future::Future;
56-
use std::io::Result;
57-
use std::marker::PhantomData;
58-
5955
pub mod fmt;
6056
pub mod pinned;
6157
pub mod time;
@@ -67,133 +63,5 @@ mod imp;
6763
#[path = "rt_tokio/mod.rs"]
6864
mod imp;
6965

70-
/// Spawns a task on current thread.
71-
///
72-
/// # Panics
73-
///
74-
/// This function will panic when not being executed from within the prokio runtime.
75-
#[inline(always)]
76-
pub fn spawn_local<F>(f: F)
77-
where
78-
F: Future<Output = ()> + 'static,
79-
{
80-
imp::spawn_local(f);
81-
}
82-
83-
/// A Runtime Builder.
84-
#[derive(Debug)]
85-
pub struct RuntimeBuilder {
86-
worker_threads: usize,
87-
}
88-
89-
impl Default for RuntimeBuilder {
90-
fn default() -> Self {
91-
Self {
92-
worker_threads: imp::get_default_runtime_size(),
93-
}
94-
}
95-
}
96-
97-
impl RuntimeBuilder {
98-
/// Creates a new Runtime Builder.
99-
pub fn new() -> Self {
100-
Self::default()
101-
}
102-
103-
/// Sets the number of worker threads the Runtime will use.
104-
///
105-
/// # Default
106-
///
107-
/// The default number of worker threads is the number of available logical CPU cores.
108-
///
109-
/// # Note
110-
///
111-
/// This setting has no effect if current platform has no thread support (e.g.: WebAssembly).
112-
pub fn worker_threads(&mut self, val: usize) -> &mut Self {
113-
self.worker_threads = val;
114-
115-
self
116-
}
117-
118-
/// Creates a Runtime.
119-
pub fn build(&mut self) -> Result<Runtime> {
120-
Ok(Runtime {
121-
inner: imp::Runtime::new(self.worker_threads)?,
122-
})
123-
}
124-
}
125-
126-
/// The Prokio Runtime.
127-
#[derive(Debug, Clone, Default)]
128-
pub struct Runtime {
129-
inner: imp::Runtime,
130-
}
131-
132-
impl Runtime {
133-
/// Creates a runtime Builder.
134-
pub fn builder() -> RuntimeBuilder {
135-
RuntimeBuilder::new()
136-
}
137-
138-
/// Spawns a task with it pinned to a worker thread.
139-
///
140-
/// This can be used to execute non-Send futures without blocking the current thread.
141-
///
142-
/// [`spawn_local`] is available with tasks executed with `spawn_pinned`.
143-
#[inline(always)]
144-
pub fn spawn_pinned<F, Fut>(&self, create_task: F)
145-
where
146-
F: FnOnce() -> Fut,
147-
F: Send + 'static,
148-
Fut: Future<Output = ()> + 'static,
149-
{
150-
self.inner.spawn_pinned(create_task);
151-
}
152-
}
153-
154-
/// A Local Runtime Handle.
155-
///
156-
/// This type can be used to acquire a runtime handle to spawn local tasks.
157-
#[derive(Debug, Clone)]
158-
pub struct LocalHandle {
159-
inner: imp::LocalHandle,
160-
// This type is not send or sync.
161-
_marker: PhantomData<*const ()>,
162-
}
163-
164-
impl LocalHandle {
165-
/// Creates a Handle to current Runtime worker.
166-
///
167-
/// # Panics
168-
///
169-
/// This method will panic if not called within prokio Runtime.
170-
pub fn current() -> Self {
171-
let inner = imp::LocalHandle::current();
172-
173-
Self {
174-
inner,
175-
_marker: PhantomData,
176-
}
177-
}
178-
179-
/// Creates a Handle to current Runtime worker.
180-
///
181-
/// This methods will return `None` if called from outside prokio Runtime.
182-
pub fn try_current() -> Option<Self> {
183-
let inner = imp::LocalHandle::try_current()?;
184-
185-
Some(Self {
186-
inner,
187-
_marker: PhantomData,
188-
})
189-
}
190-
191-
/// Spawns a Future with current Runtime worker.
192-
#[inline(always)]
193-
pub fn spawn_local<F>(&self, f: F)
194-
where
195-
F: Future<Output = ()> + 'static,
196-
{
197-
self.inner.spawn_local(f);
198-
}
199-
}
66+
mod runtime;
67+
pub use runtime::*;

src/runtime.rs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
use std::future::Future;
2+
use std::io::Result;
3+
use std::marker::PhantomData;
4+
5+
/// Spawns a task on current thread.
6+
///
7+
/// # Panics
8+
///
9+
/// This function will panic when not being executed from within the [Runtime].
10+
#[inline(always)]
11+
pub fn spawn_local<F>(f: F)
12+
where
13+
F: Future<Output = ()> + 'static,
14+
{
15+
crate::imp::spawn_local(f);
16+
}
17+
18+
/// A Runtime Builder.
19+
#[derive(Debug)]
20+
pub struct RuntimeBuilder {
21+
worker_threads: usize,
22+
}
23+
24+
impl Default for RuntimeBuilder {
25+
fn default() -> Self {
26+
Self {
27+
worker_threads: crate::imp::get_default_runtime_size(),
28+
}
29+
}
30+
}
31+
32+
impl RuntimeBuilder {
33+
/// Creates a new Runtime Builder.
34+
pub fn new() -> Self {
35+
Self::default()
36+
}
37+
38+
/// Sets the number of worker threads the Runtime will use.
39+
///
40+
/// # Default
41+
///
42+
/// The default number of worker threads is the number of available logical CPU cores.
43+
///
44+
/// # Note
45+
///
46+
/// This setting has no effect if current platform has no thread support (e.g.: WebAssembly).
47+
pub fn worker_threads(&mut self, val: usize) -> &mut Self {
48+
self.worker_threads = val;
49+
50+
self
51+
}
52+
53+
/// Creates a Runtime.
54+
pub fn build(&mut self) -> Result<Runtime> {
55+
Ok(Runtime {
56+
inner: crate::imp::Runtime::new(self.worker_threads)?,
57+
})
58+
}
59+
}
60+
61+
/// An asynchronous Runtime.
62+
#[derive(Debug, Clone, Default)]
63+
pub struct Runtime {
64+
inner: crate::imp::Runtime,
65+
}
66+
67+
impl Runtime {
68+
/// Creates a runtime Builder.
69+
pub fn builder() -> RuntimeBuilder {
70+
RuntimeBuilder::new()
71+
}
72+
73+
/// Spawns a task with it pinned to a worker thread.
74+
///
75+
/// This can be used to execute non-Send futures without blocking the current thread.
76+
///
77+
/// [`spawn_local`] is available with tasks executed with `spawn_pinned`.
78+
#[inline(always)]
79+
pub fn spawn_pinned<F, Fut>(&self, create_task: F)
80+
where
81+
F: FnOnce() -> Fut,
82+
F: Send + 'static,
83+
Fut: Future<Output = ()> + 'static,
84+
{
85+
self.inner.spawn_pinned(create_task);
86+
}
87+
}
88+
89+
/// A Local Runtime Handle.
90+
///
91+
/// This type can be used to acquire a runtime handle to spawn local tasks.
92+
#[derive(Debug, Clone)]
93+
pub struct LocalHandle {
94+
inner: crate::imp::LocalHandle,
95+
// This type is not send or sync.
96+
_marker: PhantomData<*const ()>,
97+
}
98+
99+
impl LocalHandle {
100+
/// Creates a Handle to current Runtime worker.
101+
///
102+
/// # Panics
103+
///
104+
/// This method will panic if not called from within the [Runtime].
105+
pub fn current() -> Self {
106+
let inner = crate::imp::LocalHandle::current();
107+
108+
Self {
109+
inner,
110+
_marker: PhantomData,
111+
}
112+
}
113+
114+
/// Creates a Handle to current Runtime worker.
115+
///
116+
/// This methods will return `None` if called from outside the [Runtime].
117+
pub fn try_current() -> Option<Self> {
118+
let inner = crate::imp::LocalHandle::try_current()?;
119+
120+
Some(Self {
121+
inner,
122+
_marker: PhantomData,
123+
})
124+
}
125+
126+
/// Spawns a Future with current [Runtime] worker.
127+
#[inline(always)]
128+
pub fn spawn_local<F>(&self, f: F)
129+
where
130+
F: Future<Output = ()> + 'static,
131+
{
132+
self.inner.spawn_local(f);
133+
}
134+
}

0 commit comments

Comments
 (0)