mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Add back lua lifetime to scheduler
This commit is contained in:
parent
6e83958653
commit
0dbf466817
5 changed files with 8 additions and 8 deletions
|
@ -3,7 +3,7 @@ use mlua::prelude::*;
|
|||
|
||||
use super::{IntoLuaOwnedThread, Scheduler};
|
||||
|
||||
impl<'lua, 'fut> Scheduler<'fut>
|
||||
impl<'lua, 'fut> Scheduler<'lua, 'fut>
|
||||
where
|
||||
'lua: 'fut,
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ use tokio::task::LocalSet;
|
|||
|
||||
use super::Scheduler;
|
||||
|
||||
impl<'lua, 'fut> Scheduler<'fut>
|
||||
impl<'lua, 'fut> Scheduler<'lua, 'fut>
|
||||
where
|
||||
'lua: 'fut,
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ use super::{
|
|||
IntoLuaOwnedThread, Scheduler,
|
||||
};
|
||||
|
||||
impl<'lua, 'fut> Scheduler<'fut>
|
||||
impl<'lua, 'fut> Scheduler<'lua, 'fut>
|
||||
where
|
||||
'lua: 'fut,
|
||||
{
|
||||
|
|
|
@ -33,16 +33,16 @@ type SchedulerFuture<'fut> = Pin<Box<dyn Future<Output = ()> + 'fut>>;
|
|||
and data will remain unchanged and accessible from all clones.
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Scheduler<'fut> {
|
||||
lua: &'static Lua,
|
||||
pub(crate) struct Scheduler<'lua, 'fut> {
|
||||
lua: &'lua Lua,
|
||||
state: Arc<SchedulerState>,
|
||||
threads: Arc<RefCell<VecDeque<SchedulerThread>>>,
|
||||
thread_senders: Arc<RefCell<HashMap<SchedulerThreadId, SchedulerThreadSender>>>,
|
||||
futures: Arc<AsyncMutex<FuturesUnordered<SchedulerFuture<'fut>>>>,
|
||||
}
|
||||
|
||||
impl<'fut> Scheduler<'fut> {
|
||||
pub fn new(lua: &'static Lua) -> Self {
|
||||
impl<'lua, 'fut> Scheduler<'lua, 'fut> {
|
||||
pub fn new(lua: &'lua Lua) -> Self {
|
||||
Self {
|
||||
lua,
|
||||
state: Arc::new(SchedulerState::new()),
|
||||
|
|
|
@ -55,7 +55,7 @@ impl LuaSchedulerExt for Lua {
|
|||
.app_data_ref::<&Scheduler>()
|
||||
.expect("Lua struct is missing scheduler");
|
||||
// FIXME: `self` escapes outside of method because we are borrowing `func`?
|
||||
// For now we solve this by just using a &'static Lua reference everywhere
|
||||
// For now we solve this by using 'static lifetimes for this entire method
|
||||
sched.schedule_future_thread(thread, future)?;
|
||||
Ok(())
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue