Skip to content

Commit 72650dd

Browse files
author
Alexey Andreev
committed
Revert "Merge remote-tracking branch 'origin/notification_optimization' into vendored/stoppable_module"
This reverts commit 4e404de, reversing changes made to fea6c06.
1 parent 4dca3ec commit 72650dd

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

src/txapi.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::eventfd;
66
use std::os::unix::io::{AsRawFd, RawFd};
77
use std::io;
88
use mlua::Lua;
9-
use std::sync::{Arc, atomic};
109

1110
pub type Task = Box<dyn FnOnce(&Lua) -> Result<(), ChannelError> + Send>;
1211
type TaskSender = async_channel::Sender<Task>;
@@ -27,19 +26,17 @@ pub enum ChannelError {
2726
pub struct Dispatcher {
2827
pub(crate) task_tx: TaskSender,
2928
pub(crate) eventfd: eventfd::EventFd,
30-
pub(crate) waiters: Arc<atomic::AtomicUsize>,
3129
}
3230

3331
impl Dispatcher {
34-
pub fn new(task_tx: TaskSender, eventfd: eventfd::EventFd, waiters: Arc<atomic::AtomicUsize>) -> Self {
35-
Self { task_tx, eventfd, waiters }
32+
pub fn new(task_tx: TaskSender, eventfd: eventfd::EventFd) -> Self {
33+
Self { task_tx, eventfd }
3634
}
3735

3836
pub fn try_clone(&self) -> std::io::Result<Self> {
3937
Ok(Self {
4038
task_tx: self.task_tx.clone(),
4139
eventfd: self.eventfd.try_clone()?,
42-
waiters: self.waiters.clone(),
4340
})
4441
}
4542

@@ -86,12 +83,11 @@ impl Dispatcher {
8683
pub struct Executor {
8784
task_rx: TaskReceiver,
8885
eventfd: eventfd::EventFd,
89-
waiters: Arc<atomic::AtomicUsize>,
9086
}
9187

9288
impl Executor {
93-
pub fn new(task_rx: TaskReceiver, eventfd: eventfd::EventFd, waiters: Arc<atomic::AtomicUsize>) -> Self {
94-
Self { task_rx, eventfd, waiters }
89+
pub fn new(task_rx: TaskReceiver, eventfd: eventfd::EventFd) -> Self {
90+
Self { task_rx, eventfd }
9591
}
9692

9793
pub fn exec(&self, lua: &Lua, coio_timeout: f64) -> Result<(), ChannelError> {
@@ -103,7 +99,6 @@ impl Executor {
10399
};
104100

105101
let _ = self.eventfd.coio_read(coio_timeout);
106-
self.waiters.fetch_sub(1, atomic::Ordering::Relaxed);
107102
}
108103
}
109104

@@ -132,17 +127,8 @@ impl Executor {
132127
Ok(Self {
133128
task_rx: self.task_rx.clone(),
134129
eventfd: self.eventfd.try_clone()?,
135-
waiters: self.waiters.clone(),
136130
})
137131
}
138-
139-
pub fn len(&self) -> usize {
140-
self.task_rx.len()
141-
}
142-
143-
pub fn waiters(&self) -> usize {
144-
self.waiters.load(atomic::Ordering::Relaxed)
145-
}
146132
}
147133

148134
impl AsRawFd for Executor {
@@ -154,10 +140,6 @@ impl AsRawFd for Executor {
154140
pub fn channel(buffer: usize) -> io::Result<(Dispatcher, Executor)> {
155141
let (task_tx, task_rx) = async_channel::bounded(buffer);
156142
let efd = eventfd::EventFd::new(0, false)?;
157-
let waiters = Arc::new(atomic::AtomicUsize::new(0));
158143

159-
Ok((
160-
Dispatcher::new(task_tx, efd.try_clone()?, waiters.clone()),
161-
Executor::new(task_rx, efd, waiters),
162-
))
144+
Ok((Dispatcher::new(task_tx, efd.try_clone()?), Executor::new(task_rx, efd)))
163145
}

0 commit comments

Comments
 (0)