fn new(
		processes: Option<usize>, threads: Option<usize>, tasks: Option<usize>,
		resources: Resources,
	) -> Result<Self, SpawnError> {
		let processes = processes.unwrap_or(3); // TODO!
		let mut processes_vec = Vec::with_capacity(processes);
		for _ in 0..processes {
			let child = spawn(
				resources,
				FnOnce!(move |parent| {
					tokio::runtime::Builder::new()
						.threaded_scheduler()
						.enable_all()
						.build()
						.unwrap()
						.block_on(async {
							let receiver = Receiver::<Option<Request>>::new(parent);
							let sender = Sender::<Result<Response, Panicked>>::new(parent);

							let thread_pool = ThreadPool::new(threads, tasks).unwrap();

							while let Some(work) = receiver.recv().await.unwrap() {
								let ret = panic::catch_unwind(panic::AssertUnwindSafe(|| {
									work.into_box().call_once_box((&thread_pool,))
								}));
								let ret = match ret {
									Ok(t) => panic::AssertUnwindSafe(t).catch_unwind().await,
									Err(e) => Err(e),
								}
								.map_err(Panicked::from);
								sender.send(ret).await;
							}
						})
				}),
			)
			.block();
			if let Err(err) = child {
				for Process { sender, .. } in processes_vec {
					// TODO: select
					sender.send(None).block();
				}
				return Err(err);
			}
			let child = child.unwrap();

			let sender = Sender::new(child);
			let receiver = Receiver::new(child);

			let (queue, received, tail) = (VecDeque::new(), 0, 0);

			processes_vec.push(Process {
				sender,
				receiver,
				inner: Mutex::new(ProcessInner {
					queue,
					received,
					tail,
				}),
				synchronize: Synchronize::new(),
			})
		}
		let i = RoundRobin::new(0, processes_vec.len());
		Ok(Self {
			processes: processes_vec,
			i,
		})
	}
// TODO: work out what's triggering this
work out what's triggering this
work out what ' s triggering this
fn new(
		processes: Option<usize>, threads: Option<usize>, tasks: Option<usize>,
		resources: Resources,
	) -> Result<Self, SpawnError> {
		let processes = processes.unwrap_or(3); // TODO!
		let mut processes_vec = Vec::with_capacity(processes);
		for _ in 0..processes {
			let child = spawn(
				resources,
				FnOnce!(move |parent| {
					tokio::runtime::Builder::new()
						.threaded_scheduler()
						.enable_all()
						.build()
						.unwrap()
						.block_on(async {
							let receiver = Receiver::<Option<Request>>::new(parent);
							let sender = Sender::<Result<Response, Panicked>>::new(parent);
							let thread_pool = ThreadPool::new(threads, tasks).unwrap();
							while let Some(work) = receiver.recv().await.unwrap() {
								let ret = panic::catch_unwind(panic::AssertUnwindSafe(|| {
									work.into_box().call_once_box((&thread_pool,))
								}));
								let ret = match ret {
									Ok(t) => panic::AssertUnwindSafe(t).catch_unwind().await,
									Err(e) => Err(e),
								}
								.map_err(Panicked::from);
								sender.send(ret).await;
							}
						})
				}),
			)
			.block();
			if let Err(err) = child {
				for Process { sender, .. } in processes_vec {
					// TODO: select
					sender.send(None).block();
				}
				return Err(err);
			}
			let child = child.unwrap();
			let sender = Sender::new(child);
			let receiver = Receiver::new(child);
			let (queue, received, tail) = (VecDeque::new(), 0, 0);
			processes_vec.push(Process {
				sender,
				receiver,
				inner: Mutex::new(ProcessInner {
					queue,
					received,
					tail,
				}),
				synchronize: Synchronize::new(),
			})
		}
		let i = RoundRobin::new(0, processes_vec.len());
		Ok(Self {
			processes: processes_vec,
			i,
		})
	}
fn new ( processes : Option < usize > , threads : Option < usize > , tasks : Option < usize > , resources : Resources , ) -> Result < Self , SpawnError > { let processes = processes . unwrap_or ( 3 ) ; // TODO! let mut processes_vec = Vec :: with_capacity ( processes ) ; for _ in 0 .. processes { let child = spawn ( resources , FnOnce ! ( move parent { tokio runtime Builder new ( ) threaded_scheduler ( ) enable_all ( ) build ( ) unwrap ( ) block_on ( async { let receiver Receiver Option Request new ( parent ) let sender Sender Result Response Panicked new ( parent ) let thread_pool ThreadPool new ( threads tasks ) unwrap ( ) while let Some ( work ) receiver recv ( ) await unwrap ( ) { let ret panic catch_unwind ( panic AssertUnwindSafe ( { work into_box ( ) call_once_box ( ( thread_pool ) ) } ) ) let ret match ret { Ok ( t ) panic AssertUnwindSafe ( t ) catch_unwind ( ) await Err ( e ) Err ( e ) } map_err ( Panicked from ) sender send ( ret ) await } } ) } ) , ) . block ( ) ; if let Err ( err ) = child { for Process { sender , .. } in processes_vec { // TODO: select sender . send ( None ) . block ( ) ; } return Err ( err ) ; } let child = child . unwrap ( ) ; let sender = Sender :: new ( child ) ; let receiver = Receiver :: new ( child ) ; let ( queue , received , tail ) = ( VecDeque :: new ( ) , 0 , 0 ) ; processes_vec . push ( Process { sender , receiver , inner : Mutex :: new ( ProcessInner { queue , received , tail , } ) , synchronize : Synchronize :: new ( ) , } ) } let i = RoundRobin :: new ( 0 , processes_vec . len ( ) ) ; Ok ( Self { processes : processes_vec , i , } ) }
TODO: work out what's triggering this
TODO : work out what ' s triggering this
processes
Option<usize>
threads
Option<usize>
tasks
Option<usize>
resources
Resources