use gzb_binary_69::Reader; use flume::unbounded as FlumeUnBounded; use flume::bounded as FlumeBounded; use flume::Receiver as FlumeReveiver; use flume::Sender as FlumeSender; use crate::workers::Signal; use std::sync::Arc; use tokio::sync::{Notify,Mutex}; pub struct Config{ pub path:String, pub frame:u64, pub disk_writers:u64 } impl Config{ pub fn new(path:String,frame_size:u64,num_of_writers:u64)->Config{ Config{ path:path, frame:frame_size, disk_writers:num_of_writers } } } pub enum DiskMessage{ Expand((Arc>,Arc)), Add((u64,Vec,Arc>,Arc)) } #[derive(Clone)] pub struct DiskConfig{ pub receiver:FlumeReveiver, pub path:String, pub frame_size:u64 } impl DiskConfig{ pub fn new(p:String,frame_size:u64)->(DiskConfig,FlumeSender){ // let (sender,receiver) = FlumeBounded(5000); let (sender, receiver) = FlumeUnBounded(); return ( DiskConfig{ receiver:receiver, path:p, frame_size:frame_size }, sender ); } } /* struct MapAddMessage{ value:Vec, signal:Arc>, notify:Arc } */ pub enum MapMessage{ Add((Vec,Arc>,Arc)), Print } pub struct MapConfig{ pub disk_sender:FlumeSender, pub reader:Reader, pub receiver:FlumeReveiver, pub items:Vec, pub frame_size:u64 } impl MapConfig{ pub fn new(r:Reader,disk_sender:FlumeSender,items:Vec,frame_size:u64)->(MapConfig,FlumeSender){ // let (sender, receiver) = FlumeBounded(5000); let (sender, receiver) = FlumeUnBounded(); return ( MapConfig{ disk_sender:disk_sender, reader:r, receiver:receiver, items:items, frame_size:frame_size }, sender ); } }