-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update mediasoup * perf: use thread pool for worker and async executor * chore: bump version to 0.3.0 * fix: use fixed deadlock version for mediasoup
- Loading branch information
Showing
8 changed files
with
79 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use async_executor::{Executor, Task}; | ||
use futures_lite::future; | ||
use once_cell::sync::Lazy; | ||
use std::future::Future; | ||
use std::sync::Arc; | ||
|
||
static EXECUTOR: Lazy<Arc<Executor<'static>>> = Lazy::new(|| { | ||
let executor = Arc::new(Executor::new()); | ||
let thread_count = std::cmp::max(2, num_cpus::get()); | ||
|
||
for _ in 0..thread_count { | ||
create_thread_for_executor(Arc::clone(&executor)); | ||
} | ||
executor | ||
}); | ||
|
||
pub fn executor() -> Arc<Executor<'static>> { | ||
EXECUTOR.clone() | ||
} | ||
|
||
pub fn spawn<T>(task: T) -> Task<()> | ||
where | ||
T: Future<Output = ()> + Send + 'static, | ||
{ | ||
executor().spawn(task) | ||
} | ||
|
||
fn create_thread_for_executor(executor: Arc<Executor<'static>>) { | ||
let builder = std::thread::Builder::new().name("ex-mediasoup-worker".into()); | ||
let _ = builder.spawn(move || { | ||
let _ = future::block_on(executor.run(async { | ||
let future = future::pending(); | ||
let () = future.await; | ||
})); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters