From c5ef83d5b0100d9ed3e3efb01c5ba4b6424e73ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Mon, 29 Nov 2021 16:05:33 +0100 Subject: [PATCH] ts/runtime: use a directory for executor module This will ease the introduction of other concepts which are required for our own executor implementation. --- .../{executor.rs => executor/context.rs} | 22 +---------- .../threadshare/src/runtime/executor/mod.rs | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 20 deletions(-) rename generic/threadshare/src/runtime/{executor.rs => executor/context.rs} (96%) create mode 100644 generic/threadshare/src/runtime/executor/mod.rs diff --git a/generic/threadshare/src/runtime/executor.rs b/generic/threadshare/src/runtime/executor/context.rs similarity index 96% rename from generic/threadshare/src/runtime/executor.rs rename to generic/threadshare/src/runtime/executor/context.rs index 215bf23f..67ae7bf6 100644 --- a/generic/threadshare/src/runtime/executor.rs +++ b/generic/threadshare/src/runtime/executor/context.rs @@ -1,5 +1,5 @@ // Copyright (C) 2018-2020 Sebastian Dröge -// Copyright (C) 2019-2020 François Laignel +// Copyright (C) 2019-2021 François Laignel // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -16,24 +16,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -//! The `Executor` for the `threadshare` GStreamer plugins framework. -//! -//! The [`threadshare`]'s `Executor` consists in a set of [`Context`]s. Each [`Context`] is -//! identified by a `name` and runs a loop in a dedicated `thread`. Users can use the [`Context`] -//! to spawn `Future`s. `Future`s are asynchronous processings which allow waiting for resources -//! in a non-blocking way. Examples of non-blocking operations are: -//! -//! * Waiting for an incoming packet on a Socket. -//! * Waiting for an asynchronous `Mutex` `lock` to succeed. -//! * Waiting for a time related `Future`. -//! -//! `Element` implementations should use [`PadSrc`] & [`PadSink`] which provides high-level features. -//! -//! [`threadshare`]: ../../index.html -//! [`Context`]: struct.Context.html -//! [`PadSrc`]: ../pad/struct.PadSrc.html -//! [`PadSink`]: ../pad/struct.PadSink.html - use futures::channel::oneshot; use futures::future::BoxFuture; use futures::prelude::*; @@ -54,7 +36,7 @@ use std::task::Poll; use std::thread; use std::time::Duration; -use super::RUNTIME_CAT; +use crate::runtime::RUNTIME_CAT; // We are bound to using `sync` for the `runtime` `Mutex`es. Attempts to use `async` `Mutex`es // lead to the following issues: diff --git a/generic/threadshare/src/runtime/executor/mod.rs b/generic/threadshare/src/runtime/executor/mod.rs new file mode 100644 index 00000000..48395e5f --- /dev/null +++ b/generic/threadshare/src/runtime/executor/mod.rs @@ -0,0 +1,39 @@ +// Copyright (C) 2018-2020 Sebastian Dröge +// Copyright (C) 2019-2021 François Laignel +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the +// Free Software Foundation, Inc., 51 Franklin Street, Suite 500, +// Boston, MA 02110-1335, USA. + +//! The `Executor` for the `threadshare` GStreamer plugins framework. +//! +//! The [`threadshare`]'s `Executor` consists in a set of [`Context`]s. Each [`Context`] is +//! identified by a `name` and runs a loop in a dedicated `thread`. Users can use the [`Context`] +//! to spawn `Future`s. `Future`s are asynchronous processings which allow waiting for resources +//! in a non-blocking way. Examples of non-blocking operations are: +//! +//! * Waiting for an incoming packet on a Socket. +//! * Waiting for an asynchronous `Mutex` `lock` to succeed. +//! * Waiting for a time related `Future`. +//! +//! `Element` implementations should use [`PadSrc`] & [`PadSink`] which provides high-level features. +//! +//! [`threadshare`]: ../../index.html +//! [`PadSrc`]: ../pad/struct.PadSrc.html +//! [`PadSink`]: ../pad/struct.PadSink.html + +mod context; +pub use context::{ + block_on, block_on_or_add_sub_task, yield_now, Context, JoinHandle, SubTaskOutput, TaskId, +};