Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Laignel <francois@centricular.com>2023-10-02 12:06:47 +0300
committerFrançois Laignel <francois@centricular.com>2023-10-02 16:09:26 +0300
commita1ad3379ca07928bfa1bb4381bfa9aae3f69d92a (patch)
tree0fde53c3d018f58805a33c0505dd907e44f8f8e1 /generic
parent450ffbe4523be05f9afb21cd88ee097c78d57f3f (diff)
generic: threadshare: macOS fixes
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1344>
Diffstat (limited to 'generic')
-rw-r--r--generic/threadshare/src/runtime/executor/async_wrapper.rs4
-rw-r--r--generic/threadshare/src/runtime/executor/reactor.rs1
-rw-r--r--generic/threadshare/src/runtime/executor/reactor/kqueue.rs77
-rw-r--r--generic/threadshare/src/runtime/executor/reactor/unix.rs1
-rw-r--r--generic/threadshare/src/runtime/executor/reactor/windows.rs1
-rw-r--r--generic/threadshare/tests/tcpclientsrc.rs4
6 files changed, 23 insertions, 65 deletions
diff --git a/generic/threadshare/src/runtime/executor/async_wrapper.rs b/generic/threadshare/src/runtime/executor/async_wrapper.rs
index 0e23691ac..472050288 100644
--- a/generic/threadshare/src/runtime/executor/async_wrapper.rs
+++ b/generic/threadshare/src/runtime/executor/async_wrapper.rs
@@ -94,10 +94,10 @@ pub struct Async<T: Send + 'static> {
pub(super) source: Arc<Source>,
/// The inner I/O handle.
- io: Option<T>,
+ pub(super) io: Option<T>,
// The [`Handle`] on the [`Scheduler`] on which this Async wrapper is registered.
- sched: scheduler::HandleWeak,
+ pub(super) sched: scheduler::HandleWeak,
}
impl<T: Send + 'static> Unpin for Async<T> {}
diff --git a/generic/threadshare/src/runtime/executor/reactor.rs b/generic/threadshare/src/runtime/executor/reactor.rs
index 4e297385f..e1f2221cd 100644
--- a/generic/threadshare/src/runtime/executor/reactor.rs
+++ b/generic/threadshare/src/runtime/executor/reactor.rs
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: MIT OR Apache-2.0
// This is based on https://github.com/smol-rs/async-io
// with adaptations by:
//
diff --git a/generic/threadshare/src/runtime/executor/reactor/kqueue.rs b/generic/threadshare/src/runtime/executor/reactor/kqueue.rs
index 9f31af98b..2ca28bccf 100644
--- a/generic/threadshare/src/runtime/executor/reactor/kqueue.rs
+++ b/generic/threadshare/src/runtime/executor/reactor/kqueue.rs
@@ -1,20 +1,15 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
+// This is based on https://github.com/smol-rs/async-io
-use crate::os::kqueue::Signal;
-
-use polling::os::kqueue::{PollerKqueueExt, Process, ProcessOps, Signal as PollSignal};
-use polling::{Event, PollMode, Poller};
+use polling::{Event, Poller};
use std::fmt;
use std::io::Result;
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
-use std::process::Child;
/// The raw registration into the reactor.
-///
-/// This needs to be public, since it is technically exposed through the `QueueableSealed` trait.
#[doc(hidden)]
-pub enum Registration {
+pub struct Registration {
/// Raw file descriptor for readability/writability.
///
///
@@ -22,22 +17,12 @@ pub enum Registration {
///
/// This describes a valid file descriptor that has not been `close`d. It will not be
/// closed while this object is alive.
- Fd(RawFd),
-
- /// Raw signal number for signal delivery.
- Signal(Signal),
-
- /// Process for process termination.
- Process(Child),
+ raw: RawFd,
}
impl fmt::Debug for Registration {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- Self::Fd(raw) => fmt::Debug::fmt(raw, f),
- Self::Signal(signal) => fmt::Debug::fmt(signal, f),
- Self::Process(process) => fmt::Debug::fmt(process, f),
- }
+ fmt::Debug::fmt(&self.raw, f)
}
}
@@ -48,61 +33,31 @@ impl Registration {
///
/// The provided file descriptor must be valid and not be closed while this object is alive.
pub(crate) unsafe fn new(f: impl AsFd) -> Self {
- Self::Fd(f.as_fd().as_raw_fd())
+ Self {
+ raw: f.as_fd().as_raw_fd(),
+ }
}
/// Registers the object into the reactor.
#[inline]
pub(crate) fn add(&self, poller: &Poller, token: usize) -> Result<()> {
- match self {
- Self::Fd(raw) => {
- // SAFETY: This object's existence validates the invariants of Poller::add
- unsafe { poller.add(*raw, Event::none(token)) }
- }
- Self::Signal(signal) => {
- poller.add_filter(PollSignal(signal.0), token, PollMode::Oneshot)
- }
- Self::Process(process) => poller.add_filter(
- unsafe { Process::new(process, ProcessOps::Exit) },
- token,
- PollMode::Oneshot,
- ),
- }
+ // SAFETY: This object's existence validates the invariants of Poller::add
+ unsafe { poller.add(self.raw, Event::none(token)) }
}
/// Re-registers the object into the reactor.
#[inline]
pub(crate) fn modify(&self, poller: &Poller, interest: Event) -> Result<()> {
- match self {
- Self::Fd(raw) => {
- // SAFETY: self.raw is a valid file descriptor
- let fd = unsafe { BorrowedFd::borrow_raw(*raw) };
- poller.modify(fd, interest)
- }
- Self::Signal(signal) => {
- poller.modify_filter(PollSignal(signal.0), interest.key, PollMode::Oneshot)
- }
- Self::Process(process) => poller.modify_filter(
- unsafe { Process::new(process, ProcessOps::Exit) },
- interest.key,
- PollMode::Oneshot,
- ),
- }
+ // SAFETY: self.raw is a valid file descriptor
+ let fd = unsafe { BorrowedFd::borrow_raw(self.raw) };
+ poller.modify(fd, interest)
}
/// Deregisters the object from the reactor.
#[inline]
pub(crate) fn delete(&self, poller: &Poller) -> Result<()> {
- match self {
- Self::Fd(raw) => {
- // SAFETY: self.raw is a valid file descriptor
- let fd = unsafe { BorrowedFd::borrow_raw(*raw) };
- poller.delete(fd)
- }
- Self::Signal(signal) => poller.delete_filter(PollSignal(signal.0)),
- Self::Process(process) => {
- poller.delete_filter(unsafe { Process::new(process, ProcessOps::Exit) })
- }
- }
+ // SAFETY: self.raw is a valid file descriptor
+ let fd = unsafe { BorrowedFd::borrow_raw(self.raw) };
+ poller.delete(fd)
}
}
diff --git a/generic/threadshare/src/runtime/executor/reactor/unix.rs b/generic/threadshare/src/runtime/executor/reactor/unix.rs
index b2f9b1b20..75ac60ac7 100644
--- a/generic/threadshare/src/runtime/executor/reactor/unix.rs
+++ b/generic/threadshare/src/runtime/executor/reactor/unix.rs
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
+// This is based on https://github.com/smol-rs/async-io
use polling::{Event, Poller};
diff --git a/generic/threadshare/src/runtime/executor/reactor/windows.rs b/generic/threadshare/src/runtime/executor/reactor/windows.rs
index 1c92f00a6..e29056044 100644
--- a/generic/threadshare/src/runtime/executor/reactor/windows.rs
+++ b/generic/threadshare/src/runtime/executor/reactor/windows.rs
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
+// This is based on https://github.com/smol-rs/async-io
use polling::{Event, Poller};
use std::fmt;
diff --git a/generic/threadshare/tests/tcpclientsrc.rs b/generic/threadshare/tests/tcpclientsrc.rs
index a450452eb..c6274b793 100644
--- a/generic/threadshare/tests/tcpclientsrc.rs
+++ b/generic/threadshare/tests/tcpclientsrc.rs
@@ -43,7 +43,7 @@ fn test_push() {
let handler = thread::spawn(move || {
use std::net;
- let listener = net::TcpListener::bind("0.0.0.0:5000").unwrap();
+ let listener = net::TcpListener::bind("0.0.0.0:5010").unwrap();
listening_tx.send(()).unwrap();
let stream = listener.incoming().next().unwrap();
let buffer = [0; 160];
@@ -59,7 +59,7 @@ fn test_push() {
let caps = gst::Caps::builder("foo/bar").build();
let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc")
.property("caps", &caps)
- .property("port", 5000i32)
+ .property("port", 5010i32)
.build()
.unwrap();
let appsink = gst_app::AppSink::builder()