Skip to content

Commit

Permalink
native: Scrub winit references
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone authored and torokati44 committed Mar 13, 2024
1 parent 8ebf008 commit 7e2bd09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions native/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ struct TaskHandle {
handle: Index,

/// The executor the task belongs to.
executor: Arc<Mutex<WinitAsyncExecutor>>,
executor: Arc<Mutex<NativeAsyncExecutor>>,
}

impl TaskHandle {
/// Construct a handle to a given task.
fn for_task(task: Index, executor: Arc<Mutex<WinitAsyncExecutor>>) -> Self {
fn for_task(task: Index, executor: Arc<Mutex<NativeAsyncExecutor>>) -> Self {
Self {
handle: task,
executor,
Expand Down Expand Up @@ -121,7 +121,7 @@ impl TaskHandle {
);
}

pub struct WinitAsyncExecutor {
pub struct NativeAsyncExecutor {
/// List of all spawned tasks.
task_queue: Arena<Task>,

Expand All @@ -132,25 +132,25 @@ pub struct WinitAsyncExecutor {
self_ref: Weak<Mutex<Self>>,

/// Event injector for the main thread event loop.
event_loop: EventSender,
event_sender: EventSender,

/// Whether or not we have already queued a `TaskPoll` event.
waiting_for_poll: bool,
}

impl WinitAsyncExecutor {
/// Construct a new executor for the winit event loop.
impl NativeAsyncExecutor {
/// Construct a new executor that's able to communicate back with the given EventSender.
///
/// This function returns the executor itself, plus the `Sender` necessary
/// to spawn new tasks.
pub fn new(event_loop: EventSender) -> (Arc<Mutex<Self>>, Sender<OwnedFuture<(), Error>>) {
pub fn new(event_sender: EventSender) -> (Arc<Mutex<Self>>, Sender<OwnedFuture<(), Error>>) {
let (send, recv) = unbounded();
let new_self = Arc::new_cyclic(|self_ref| {
Mutex::new(Self {
task_queue: Arena::new(),
channel: recv,
self_ref: self_ref.clone(),
event_loop,
event_sender,
waiting_for_poll: false,
})
});
Expand Down Expand Up @@ -199,7 +199,7 @@ impl WinitAsyncExecutor {
task.set_ready();
if !self.waiting_for_poll {
self.waiting_for_poll = true;
self.event_loop.send(RuffleEvent::TaskPoll);
self.event_sender.send(RuffleEvent::TaskPoll);
} else {
log::info!("Double polling");
}
Expand Down
6 changes: 3 additions & 3 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use navigator::ExternalNavigatorBackend;
use ruffle_core::backend::storage::MemoryStorageBackend;
use url::Url;

use executor::WinitAsyncExecutor;
use executor::NativeAsyncExecutor;

use ruffle_core::{
events::{KeyCode, MouseButton, PlayerEvent},
Expand All @@ -46,7 +46,7 @@ use ruffle_render_wgpu::{backend::WgpuRenderBackend, target::SwapChainTarget};
/// which may be lost when this Player is closed (dropped)
struct ActivePlayer {
player: Arc<Mutex<Player>>,
executor: Arc<Mutex<WinitAsyncExecutor>>,
executor: Arc<Mutex<NativeAsyncExecutor>>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -202,7 +202,7 @@ fn run(app: AndroidApp) {
};
let movie_url = Url::parse("file://movie.swf").unwrap();

let (executor, channel) = WinitAsyncExecutor::new(
let (executor, channel) = NativeAsyncExecutor::new(
sender.clone(), /*, app.create_waker()*/
);
let navigator = ExternalNavigatorBackend::new(
Expand Down

0 comments on commit 7e2bd09

Please sign in to comment.