Commit 7aff20f4 authored by Felix Häcker's avatar Felix Häcker

don't delete new task

parent 63a1871e
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk
.buildconfig .buildconfig
\ No newline at end of file .idea
This diff is collapsed.
...@@ -33,7 +33,7 @@ pub enum Message{ ...@@ -33,7 +33,7 @@ pub enum Message{
Clear, Clear,
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum Task{ pub enum Task{
GetStationById(u32), GetStationById(u32),
GetAllStations, GetAllStations,
...@@ -83,10 +83,10 @@ impl AsyncClient{ ...@@ -83,10 +83,10 @@ impl AsyncClient{
loop{ loop{
// Check if a task is available // Check if a task is available
let task = next_task.lock().unwrap().clone(); let task = next_task.lock().unwrap().clone();
if(task.is_some()){ if(task.clone().is_some()){
let mut sync_client = Client::new(&base_url); let mut sync_client = Client::new(&base_url);
// Actual work is being done here. Result get returned with mpsc::Sender. // Actual work is being done here. Result get returned with mpsc::Sender.
match task.unwrap(){ match task.clone().unwrap(){
Task::GetStationById(id) => { Task::GetStationById(id) => {
let result = vec![sync_client.get_station_by_id(id).unwrap()]; let result = vec![sync_client.get_station_by_id(id).unwrap()];
sender.send(Message::StationAdd(result)); sender.send(Message::StationAdd(result));
...@@ -132,7 +132,10 @@ impl AsyncClient{ ...@@ -132,7 +132,10 @@ impl AsyncClient{
} }
// Task is done -> Delete // Task is done -> Delete
*next_task.lock().unwrap() = None; // Make sure the task is the same one, otherwise don't delete it.
if(*next_task.lock().unwrap() == task){
*next_task.lock().unwrap() = None;
}
} }
}); });
} }
......
use restson::{RestClient,RestPath,Error}; use restson::{RestClient,RestPath,Error};
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct StationSearch { pub struct StationSearch {
pub name: String, pub name: String,
pub name_exact: bool, pub name_exact: bool,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment