mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix compilation
This commit is contained in:
parent
f5773f8d16
commit
2f4c05f2b4
@ -4,9 +4,7 @@ use maplibre::{io::scheduler::Scheduler, MapBuilder};
|
|||||||
use maplibre_winit::winit::WinitMapWindowConfig;
|
use maplibre_winit::winit::WinitMapWindowConfig;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
use crate::platform::{
|
use crate::platform::{http_client::WHATWGFetchHttpClient, NopScheduleMethod};
|
||||||
http_client::WHATWGFetchHttpClient, pool_schedule_method::WebWorkerPoolScheduleMethod,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod platform;
|
mod platform;
|
||||||
@ -39,17 +37,14 @@ pub fn wasm_bindgen_start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn create_pool_scheduler(
|
pub fn create_pool_scheduler(new_worker: js_sys::Function) -> *mut Scheduler<NopScheduleMethod> {
|
||||||
new_worker: js_sys::Function,
|
let scheduler = Scheduler::new(NopScheduleMethod);
|
||||||
) -> *mut Scheduler<WebWorkerPoolScheduleMethod> {
|
|
||||||
let scheduler = Scheduler::new(WebWorkerPoolScheduleMethod::new(new_worker));
|
|
||||||
Box::into_raw(Box::new(scheduler))
|
Box::into_raw(Box::new(scheduler))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub async fn run(scheduler_ptr: *mut Scheduler<WebWorkerPoolScheduleMethod>) {
|
pub async fn run(scheduler_ptr: *mut Scheduler<NopScheduleMethod>) {
|
||||||
let scheduler: Box<Scheduler<WebWorkerPoolScheduleMethod>> =
|
let scheduler = unsafe { Box::from_raw(scheduler_ptr) };
|
||||||
unsafe { Box::from_raw(scheduler_ptr) };
|
|
||||||
|
|
||||||
// Either call forget or the main loop to keep worker loop alive
|
// Either call forget or the main loop to keep worker loop alive
|
||||||
MapBuilder::new()
|
MapBuilder::new()
|
||||||
|
|||||||
@ -1,6 +1,21 @@
|
|||||||
|
use maplibre::error::Error;
|
||||||
|
use maplibre::io::scheduler::ScheduleMethod;
|
||||||
|
use std::future::Future;
|
||||||
|
|
||||||
pub mod http_client;
|
pub mod http_client;
|
||||||
|
|
||||||
#[cfg(target_feature = "atomics")]
|
#[cfg(target_feature = "atomics")]
|
||||||
pub mod pool;
|
pub mod pool;
|
||||||
#[cfg(target_feature = "atomics")]
|
#[cfg(target_feature = "atomics")]
|
||||||
pub mod pool_schedule_method;
|
pub mod pool_schedule_method;
|
||||||
|
|
||||||
|
pub struct NopScheduleMethod;
|
||||||
|
|
||||||
|
impl ScheduleMethod for NopScheduleMethod {
|
||||||
|
fn schedule<T>(&self, future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
||||||
|
where
|
||||||
|
T: Future<Output = ()> + 'static,
|
||||||
|
{
|
||||||
|
Err(Error::Schedule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user