Upgrade crossbeam-channel.
This commit is contained in:
parent
f4551ddf3a
commit
8fb5c16bce
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -284,12 +284,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.1.3"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"crossbeam-epoch 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-utils 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -353,6 +355,11 @@ dependencies = [
|
||||
"cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "dbghelp-sys"
|
||||
version = "0.2.0"
|
||||
@ -914,7 +921,7 @@ name = "hammond-gtk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-channel 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-channel 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gdk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2534,13 +2541,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum criterion 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f11151e2961d0483e5eb7a2ede5ed8071a460d04d2b7c89e8257aa5502b0e0b"
|
||||
"checksum criterion-plot 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f7f7c88a8d341dd9fd9e31a72ca2ca24428db79afb491852873b2c784e037e6"
|
||||
"checksum criterion-stats 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd48feb0253b2968ff3085e7f3fba6738c9ff859f420a2fb81a48986eb66da36"
|
||||
"checksum crossbeam-channel 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "862becd07e73da5746de6d9b3ba055c9bb8b10afd0d2b51155a6e30d81cd20b3"
|
||||
"checksum crossbeam-channel 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b45c6ba620feae538943c106977c6348c16ad3b03dd8aaecd25a4224345fa795"
|
||||
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
|
||||
"checksum crossbeam-deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8153ef04a7594ded05b427ffad46ddeaf22e63fd48d42b3e1e3bb4db07cae7"
|
||||
"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
|
||||
"checksum crossbeam-epoch 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2af0e75710d6181e234c8ecc79f14a97907850a541b13b0be1dd10992f2e4620"
|
||||
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
|
||||
"checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b"
|
||||
"checksum crossbeam-utils 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b71f220442ed14749909b543d4dd7ec3918cb1fe289fd96e88d0abe6ca049783"
|
||||
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
||||
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
|
||||
"checksum derive_builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c998e6ab02a828dd9735c18f154e14100e674ed08cb4e1938f0e4177543f439"
|
||||
|
||||
@ -7,7 +7,7 @@ workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.4"
|
||||
crossbeam-channel = "0.1.3"
|
||||
crossbeam-channel = "0.2.1"
|
||||
gdk = "0.8.0"
|
||||
gdk-pixbuf = "0.4.0"
|
||||
glib = "0.5.0"
|
||||
|
||||
@ -136,14 +136,14 @@ impl App {
|
||||
gtk::timeout_add(25, clone!(sender, receiver => move || {
|
||||
// Uses receiver, content, header, sender, overlay, playback
|
||||
match receiver.try_recv() {
|
||||
Ok(Action::RefreshAllViews) => content.update(),
|
||||
Ok(Action::RefreshShowsView) => content.update_shows_view(),
|
||||
Ok(Action::RefreshWidgetIfSame(id)) =>
|
||||
Some(Action::RefreshAllViews) => content.update(),
|
||||
Some(Action::RefreshShowsView) => content.update_shows_view(),
|
||||
Some(Action::RefreshWidgetIfSame(id)) =>
|
||||
content.update_widget_if_same(id),
|
||||
Ok(Action::RefreshEpisodesView) => content.update_home(),
|
||||
Ok(Action::RefreshEpisodesViewBGR) =>
|
||||
Some(Action::RefreshEpisodesView) => content.update_home(),
|
||||
Some(Action::RefreshEpisodesViewBGR) =>
|
||||
content.update_home_if_background(),
|
||||
Ok(Action::ReplaceWidget(pd)) => {
|
||||
Some(Action::ReplaceWidget(pd)) => {
|
||||
let shows = content.get_shows();
|
||||
let mut pop = shows.borrow().populated();
|
||||
pop.borrow_mut()
|
||||
@ -153,7 +153,7 @@ impl App {
|
||||
error!("Failed ot update ShowWidget {}", pd.title()))
|
||||
.ok();
|
||||
}
|
||||
Ok(Action::ShowWidgetAnimated) => {
|
||||
Some(Action::ShowWidgetAnimated) => {
|
||||
let shows = content.get_shows();
|
||||
let mut pop = shows.borrow().populated();
|
||||
pop.borrow_mut().switch_visible(
|
||||
@ -161,37 +161,37 @@ impl App {
|
||||
gtk::StackTransitionType::SlideLeft,
|
||||
);
|
||||
}
|
||||
Ok(Action::ShowShowsAnimated) => {
|
||||
Some(Action::ShowShowsAnimated) => {
|
||||
let shows = content.get_shows();
|
||||
let mut pop = shows.borrow().populated();
|
||||
pop.borrow_mut()
|
||||
.switch_visible(PopulatedState::View,
|
||||
gtk::StackTransitionType::SlideRight);
|
||||
}
|
||||
Ok(Action::HeaderBarShowTile(title)) =>
|
||||
Some(Action::HeaderBarShowTile(title)) =>
|
||||
header.switch_to_back(&title),
|
||||
Ok(Action::HeaderBarNormal) => header.switch_to_normal(),
|
||||
Ok(Action::HeaderBarShowUpdateIndicator) =>
|
||||
Some(Action::HeaderBarNormal) => header.switch_to_normal(),
|
||||
Some(Action::HeaderBarShowUpdateIndicator) =>
|
||||
header.show_update_notification(),
|
||||
Ok(Action::HeaderBarHideUpdateIndicator) =>
|
||||
Some(Action::HeaderBarHideUpdateIndicator) =>
|
||||
header.hide_update_notification(),
|
||||
Ok(Action::MarkAllPlayerNotification(pd)) => {
|
||||
Some(Action::MarkAllPlayerNotification(pd)) => {
|
||||
let notif = mark_all_notif(pd, &sender);
|
||||
notif.show(&overlay);
|
||||
}
|
||||
Ok(Action::RemoveShow(pd)) => {
|
||||
Some(Action::RemoveShow(pd)) => {
|
||||
let notif = remove_show_notif(pd, sender.clone());
|
||||
notif.show(&overlay);
|
||||
}
|
||||
Ok(Action::ErrorNotification(err)) => {
|
||||
Some(Action::ErrorNotification(err)) => {
|
||||
error!("An error notification was triggered: {}", err);
|
||||
let callback = || glib::Continue(false);
|
||||
let notif = InAppNotification::new(&err, callback,
|
||||
|| {}, UndoState::Hidden);
|
||||
notif.show(&overlay);
|
||||
},
|
||||
Ok(Action::InitEpisode(rowid)) => player.initialize_episode(rowid).unwrap(),
|
||||
Err(_) => (),
|
||||
Some(Action::InitEpisode(rowid)) => player.initialize_episode(rowid).unwrap(),
|
||||
None => (),
|
||||
}
|
||||
|
||||
Continue(true)
|
||||
|
||||
@ -113,9 +113,7 @@ impl Header {
|
||||
add_toggle.show();
|
||||
back.hide();
|
||||
show_title.hide();
|
||||
sender.send(Action::ShowShowsAnimated)
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::ShowShowsAnimated);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ use gtk::prelude::*;
|
||||
use gtk::{IsA, Widget};
|
||||
|
||||
use chrono::prelude::*;
|
||||
use crossbeam_channel::Sender;
|
||||
use crossbeam_channel::{unbounded, Sender};
|
||||
use failure::Error;
|
||||
use rayon;
|
||||
use regex::Regex;
|
||||
@ -25,7 +25,6 @@ use hammond_data::Source;
|
||||
use hammond_downloader::downloader;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
|
||||
use app::Action;
|
||||
@ -189,10 +188,7 @@ fn refresh_feed<S>(source: Option<S>, sender: Sender<Action>) -> Result<(), Erro
|
||||
where
|
||||
S: IntoIterator<Item = Source> + Send + 'static,
|
||||
{
|
||||
sender
|
||||
.send(Action::HeaderBarShowUpdateIndicator)
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::HeaderBarShowUpdateIndicator);
|
||||
|
||||
rayon::spawn(move || {
|
||||
if let Some(s) = source {
|
||||
@ -210,14 +206,8 @@ where
|
||||
.ok();
|
||||
};
|
||||
|
||||
sender
|
||||
.send(Action::HeaderBarHideUpdateIndicator)
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender
|
||||
.send(Action::RefreshAllViews)
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::HeaderBarHideUpdateIndicator);
|
||||
sender.send(Action::RefreshAllViews);
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
@ -270,20 +260,13 @@ pub fn set_image_from_path(image: >k::Image, podcast_id: i32, size: u32) -> Re
|
||||
}
|
||||
}
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
let (sender, receiver) = unbounded();
|
||||
THREADPOOL.spawn(move || {
|
||||
if let Ok(mut guard) = COVER_DL_REGISTRY.write() {
|
||||
guard.insert(podcast_id);
|
||||
}
|
||||
|
||||
if let Ok(pd) = dbqueries::get_podcast_cover_from_id(podcast_id) {
|
||||
sender
|
||||
.send(downloader::cache_image(&pd))
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
}
|
||||
|
||||
if let Ok(mut guard) = COVER_DL_REGISTRY.write() {
|
||||
if let Ok(pd) = dbqueries::get_podcast_cover_from_id(podcast_id) {
|
||||
sender.send(downloader::cache_image(&pd));
|
||||
}
|
||||
guard.remove(&podcast_id);
|
||||
}
|
||||
});
|
||||
@ -291,7 +274,7 @@ pub fn set_image_from_path(image: >k::Image, podcast_id: i32, size: u32) -> Re
|
||||
let image = image.clone();
|
||||
let s = size as i32;
|
||||
gtk::timeout_add(25, move || {
|
||||
if let Ok(path) = receiver.try_recv() {
|
||||
if let Some(path) = receiver.try_recv() {
|
||||
if let Ok(path) = path {
|
||||
if let Ok(px) = Pixbuf::new_from_file_at_scale(&path, s, s, true) {
|
||||
if let Ok(mut hashmap) = CACHED_PIXBUFS.write() {
|
||||
@ -373,16 +356,12 @@ pub fn on_import_clicked(window: >k::ApplicationWindow, sender: &Sender<Action
|
||||
refresh(Some(sources), sender)
|
||||
} else {
|
||||
let text = String::from("Failed to parse the Imported file");
|
||||
sender.send(Action::ErrorNotification(text))
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::ErrorNotification(text));
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
let text = String::from("Selected File could not be accessed.");
|
||||
sender.send(Action::ErrorNotification(text))
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::ErrorNotification(text));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -436,9 +436,8 @@ fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: &Sender<Action>) -> Resu
|
||||
manager::add(ep.rowid(), download_fold)?;
|
||||
|
||||
// Update Views
|
||||
sender
|
||||
.send(Action::RefreshEpisodesViewBGR)
|
||||
.map_err(From::from)
|
||||
sender.send(Action::RefreshEpisodesViewBGR);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_play_bttn_clicked(
|
||||
@ -452,11 +451,10 @@ fn on_play_bttn_clicked(
|
||||
widget.info.set_title(&episode);
|
||||
|
||||
// Play the episode
|
||||
sender.send(Action::InitEpisode(episode.rowid()))?;
|
||||
sender.send(Action::InitEpisode(episode.rowid()));
|
||||
// Refresh background views to match the normal/greyout title state
|
||||
sender
|
||||
.send(Action::RefreshEpisodesViewBGR)
|
||||
.map_err(From::from)
|
||||
sender.send(Action::RefreshEpisodesViewBGR);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Setup a callback that will update the progress bar.
|
||||
|
||||
@ -286,10 +286,7 @@ impl PlayerWidget {
|
||||
// Log gst errors.
|
||||
s.player.connect_error(clone!(sender => move |_, error| {
|
||||
// FIXME: should never occur and should not be user facing.
|
||||
sender.send(Action::ErrorNotification(format!("Player Error: {}", error)))
|
||||
.map_err(|err| error!("Error: {}", err))
|
||||
.ok();
|
||||
|
||||
sender.send(Action::ErrorNotification(format!("Player Error: {}", error)));
|
||||
}));
|
||||
|
||||
// The followign callbacks require `Send` but are handled by the gtk main loop
|
||||
|
||||
@ -2,7 +2,7 @@ use glib;
|
||||
use gtk;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use crossbeam_channel::{SendError, Sender};
|
||||
use crossbeam_channel::Sender;
|
||||
use failure::Error;
|
||||
use html2text;
|
||||
use open;
|
||||
@ -178,7 +178,6 @@ fn populate_listbox(
|
||||
sender: Sender<Action>,
|
||||
) -> Result<(), Error> {
|
||||
use crossbeam_channel::bounded;
|
||||
use crossbeam_channel::TryRecvError::*;
|
||||
|
||||
let count = dbqueries::get_pd_episodes_count(&pd)?;
|
||||
|
||||
@ -187,7 +186,7 @@ fn populate_listbox(
|
||||
let episodes = dbqueries::get_pd_episodeswidgets(&pd).unwrap();
|
||||
// The receiver can be dropped if there's an early return
|
||||
// like on show without episodes for example.
|
||||
sender_.send(episodes).ok();
|
||||
sender_.send(episodes);
|
||||
}));
|
||||
|
||||
if count == 0 {
|
||||
@ -200,9 +199,8 @@ fn populate_listbox(
|
||||
let show_ = show.clone();
|
||||
gtk::idle_add(move || {
|
||||
let episodes = match receiver.try_recv() {
|
||||
Ok(e) => e,
|
||||
Err(Empty) => return glib::Continue(true),
|
||||
Err(Disconnected) => return glib::Continue(false),
|
||||
Some(e) => e,
|
||||
None => return glib::Continue(true),
|
||||
};
|
||||
|
||||
let list = show_.episodes.clone();
|
||||
@ -230,18 +228,14 @@ fn on_unsub_button_clicked(pd: Arc<Podcast>, unsub_button: >k::Button, sender:
|
||||
// if pressed twice would panic.
|
||||
unsub_button.set_sensitive(false);
|
||||
|
||||
let wrap = || -> Result<(), SendError<_>> {
|
||||
sender.send(Action::RemoveShow(pd))?;
|
||||
sender.send(Action::RemoveShow(pd));
|
||||
|
||||
sender.send(Action::HeaderBarNormal)?;
|
||||
sender.send(Action::ShowShowsAnimated)?;
|
||||
// Queue a refresh after the switch to avoid blocking the db.
|
||||
sender.send(Action::RefreshShowsView)?;
|
||||
sender.send(Action::RefreshEpisodesView)?;
|
||||
Ok(())
|
||||
};
|
||||
sender.send(Action::HeaderBarNormal);
|
||||
sender.send(Action::ShowShowsAnimated);
|
||||
// Queue a refresh after the switch to avoid blocking the db.
|
||||
sender.send(Action::RefreshShowsView);
|
||||
sender.send(Action::RefreshEpisodesView);
|
||||
|
||||
wrap().map_err(|err| error!("Action Sender: {}", err)).ok();
|
||||
unsub_button.set_sensitive(true);
|
||||
}
|
||||
|
||||
@ -251,18 +245,16 @@ fn on_played_button_clicked(pd: Arc<Podcast>, episodes: >k::ListBox, sender: &
|
||||
warn!("RUN WHILE YOU STILL CAN!");
|
||||
}
|
||||
|
||||
sender
|
||||
.send(Action::MarkAllPlayerNotification(pd))
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
sender.send(Action::MarkAllPlayerNotification(pd))
|
||||
}
|
||||
|
||||
fn mark_all_watched(pd: &Podcast, sender: &Sender<Action>) -> Result<(), Error> {
|
||||
dbqueries::update_none_to_played_now(pd)?;
|
||||
// Not all widgets migth have been loaded when the mark_all is hit
|
||||
// So we will need to refresh again after it's done.
|
||||
sender.send(Action::RefreshWidgetIfSame(pd.id()))?;
|
||||
sender.send(Action::RefreshEpisodesView).map_err(From::from)
|
||||
sender.send(Action::RefreshWidgetIfSame(pd.id()));
|
||||
sender.send(Action::RefreshEpisodesView);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn mark_all_notif(pd: Arc<Podcast>, sender: &Sender<Action>) -> InAppNotification {
|
||||
@ -274,12 +266,7 @@ pub fn mark_all_notif(pd: Arc<Podcast>, sender: &Sender<Action>) -> InAppNotific
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
let undo_callback = clone!(sender => move || {
|
||||
sender.send(Action::RefreshWidgetIfSame(id))
|
||||
.map_err(|err| error!("Action Sender: {}", err))
|
||||
.ok();
|
||||
});
|
||||
|
||||
let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id)));
|
||||
let text = "Marked all episodes as listened";
|
||||
InAppNotification::new(text, callback, undo_callback, UndoState::Shown)
|
||||
}
|
||||
@ -305,20 +292,17 @@ pub fn remove_show_notif(pd: Arc<Podcast>, sender: Sender<Action>) -> InAppNotif
|
||||
.map_err(|_| error!("Failed to delete {}", pd.title()))
|
||||
.ok();
|
||||
|
||||
sender.send(Action::RefreshEpisodesView).ok();
|
||||
sender.send(Action::RefreshEpisodesView);
|
||||
}));
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
let undo_wrap = move || -> Result<(), Error> {
|
||||
utils::uningore_show(pd.id())?;
|
||||
sender.send(Action::RefreshShowsView)?;
|
||||
sender.send(Action::RefreshEpisodesView)?;
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let undo_callback = move || {
|
||||
undo_wrap().map_err(|err| error!("{}", err)).ok();
|
||||
utils::uningore_show(pd.id())
|
||||
.map_err(|err| error!("{}", err))
|
||||
.ok();
|
||||
sender.send(Action::RefreshShowsView);
|
||||
sender.send(Action::RefreshEpisodesView);
|
||||
};
|
||||
|
||||
InAppNotification::new(&text, callback, undo_callback, UndoState::Shown)
|
||||
|
||||
@ -115,9 +115,9 @@ fn on_child_activate(child: >k::FlowBoxChild, sender: &Sender<Action>) -> Resu
|
||||
.parse::<i32>()?;
|
||||
let pd = Arc::new(dbqueries::get_podcast_from_id(id)?);
|
||||
|
||||
sender.send(Action::HeaderBarShowTile(pd.title().into()))?;
|
||||
sender.send(Action::ReplaceWidget(pd))?;
|
||||
sender.send(Action::ShowWidgetAnimated)?;
|
||||
sender.send(Action::HeaderBarShowTile(pd.title().into()));
|
||||
sender.send(Action::ReplaceWidget(pd));
|
||||
sender.send(Action::ShowWidgetAnimated);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user