/// Queues a new task to the state.
/// If the start_immediately flag is set, send a StartMessage to the task handler
Queues a new task to the state.
If the start_immediately flag is set, send a StartMessage to the task handler
Queues a new task to the state . If the start_immediately flag is set send a StartMessage to the task handler
fn add_task(message: AddMessage, sender: &Sender<Message>, state: &SharedState) -> Message {
    let starting_status = if message.create_stashed {
        TaskStatus::Stashed
    } else {
        TaskStatus::Queued
    };
    let task = Task::new(message.command, message.path, starting_status);
    let task_id: usize;
    {
        let mut state = state.lock().unwrap();
        task_id = state.add_task(task);
    }
    if message.start_immediately {
        let start_message = StartMessage {
            task_ids: vec![task_id],
        };
        sender
            .send(Message::Start(start_message))
            .expect(SENDER_ERR);
    }
    create_success_message("New task added.")
}
fn add_task ( message : AddMessage , sender : & Sender < Message > , state : & SharedState ) -> Message { let starting_status = if message . create_stashed { TaskStatus :: Stashed } else { TaskStatus :: Queued } ; let task = Task :: new ( message . command , message . path , starting_status ) ; let task_id : usize ; { let mut state = state . lock ( ) . unwrap ( ) ; task_id = state . add_task ( task ) ; } if message . start_immediately { let start_message = StartMessage { task_ids : vec ! [ task_id ] , } ; sender . send ( Message :: Start ( start_message ) ) . expect ( SENDER_ERR ) ; } create_success_message ( " " ) }
Queues a new task to the state.
Queues a new task to the state .
message
AddMessage
sender
&Sender<Message>
state
&SharedState