2024-08-02 19:14:26 +00:00
|
|
|
use strafesnet_snf::bot::BotDebug;
|
2024-08-01 21:06:40 +00:00
|
|
|
|
|
|
|
pub enum Instruction{
|
|
|
|
//TODO: pass map id
|
|
|
|
Create,
|
2024-08-06 00:25:11 +00:00
|
|
|
//Delete,
|
2024-08-01 21:06:40 +00:00
|
|
|
Push{
|
2024-08-05 20:35:54 +00:00
|
|
|
ins:strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>,
|
2024-08-01 21:06:40 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
//a new worker is spawned on a thread
|
|
|
|
//create opens a new file
|
|
|
|
//push pushes an instruction to the file
|
|
|
|
|
|
|
|
pub struct Worker{
|
2024-08-06 00:25:11 +00:00
|
|
|
file:BotDebug,
|
2024-08-01 21:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{
|
|
|
|
let mut worker=Worker{
|
2024-08-06 00:25:11 +00:00
|
|
|
file:BotDebug::new().unwrap(),
|
2024-08-01 21:06:40 +00:00
|
|
|
};
|
|
|
|
crate::worker::QNWorker::new(scope,move|instruction|{
|
|
|
|
match instruction{
|
2024-08-06 00:25:11 +00:00
|
|
|
Instruction::Create=>worker.file=BotDebug::new().unwrap(),
|
|
|
|
//Instruction::Delete=>worker.file.delete().unwrap(),
|
|
|
|
Instruction::Push{ins}=>worker.file.push(ins).unwrap(),
|
2024-08-01 21:06:40 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|