Skip to content

Commit

Permalink
Fix stupid bug :P
Browse files Browse the repository at this point in the history
  • Loading branch information
funnyboy-roks committed Mar 27, 2023
1 parent e59eae8 commit 77edb93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marquee"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
authors = ["funnyboy_roks <funnyboyroks@gmail.com>"]
description = "Convert stdin into a \"marquee\" style output"
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ fn start_timer(current_str: &Arc<Mutex<String>>, options: Cli) -> thread::JoinHa
let mut prev_out = String::new();
loop {
let start = Instant::now();
let out = arc_str.lock().unwrap();
let str_value = arc_str.lock().unwrap();

// If there is no input, don't print anything
if out.is_empty() {
if str_value.is_empty() {
// Manually drop the lock on `arc_str` so that the stdin thread can put
// something new into it.
// (this is probably not the best way, but it works :shrug:)
drop(out);
drop(str_value);

// sleep so that it doesn't loop as fast as possible and devour the CPU (totally
// not known from personal experience)
Expand All @@ -127,8 +127,8 @@ fn start_timer(current_str: &Arc<Mutex<String>>, options: Cli) -> thread::JoinHa
continue;
}

let mut out = out.clone(); // Clone the String and drop the lock on `arc_str` so that we
// can receive new input
let mut out = str_value.clone(); // Clone the string so that it can be used
drop(str_value); // Drop `str_value` to remove the lock on `arc_str`.

// If `--json`, then parse the json
let json: Option<JsonInput> = options
Expand Down

0 comments on commit 77edb93

Please sign in to comment.