Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
parking_lot & 'to' parameter in TranscodeMinigroupToHls task
Browse files Browse the repository at this point in the history
  • Loading branch information
mvzolotukhin authored May 24, 2023
2 parents abea815 + d4df24f commit e6fcd8e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dispatcher"
version = "0.4.21"
version = "0.4.22"
authors = ["Andrei Nesterov <[email protected]>"]
description = "Service managing classrooms"
readme = "README.md"
Expand Down Expand Up @@ -68,6 +68,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
url = { version = "2.2.1", features = ["serde"] }
uuid = { version = "0.8", features = ["v4", "serde"] }
vec1 = { version = "1.8.0", features = ["serde"] }
parking_lot = "0.12"

[dev-dependencies]
lazy_static = "1.4"
Expand Down
2 changes: 1 addition & 1 deletion src/clients/event/layer/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use parking_lot::RwLock;
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::RwLock;
use std::task::{Context, Poll};

use anyhow::Result;
Expand Down
4 changes: 3 additions & 1 deletion src/clients/tq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ impl<'a> TaskWithOptions<'a> {
Task::ConvertMjrDumpsToStream { .. } => {
self.to = settings.to.as_deref();
}
_ => {}
Task::TranscodeMinigroupToHls { .. } => {
self.to = settings.to.as_deref();
}
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/test_helpers/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::sync::{Arc, Mutex};
use parking_lot::Mutex;
use std::sync::Arc;

use anyhow::Result;
use async_trait::async_trait;
Expand Down Expand Up @@ -252,10 +253,7 @@ impl TestPublisher {
}

pub fn flush(&self) -> Vec<OutgoingEnvelope> {
let mut messages_lock = self
.messages
.lock()
.expect("Failed to obtain messages lock");
let mut messages_lock = self.messages.lock();

(*messages_lock).drain(0..).collect::<Vec<_>>()
}
Expand All @@ -269,11 +267,7 @@ impl Publisher for TestPublisher {
.expect("Failed to parse dumped message");

parsed_message.set_topic(dump.topic());

let mut messages_lock = self
.messages
.lock()
.expect("Failed to obtain messages lock");
let mut messages_lock = self.messages.lock();

(*messages_lock).push(parsed_message);
Ok(())
Expand Down
22 changes: 10 additions & 12 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ where

#[cfg(test)]
mod tests {
use std::{
sync::{Arc, Mutex},
time::Duration,
};
use parking_lot::Mutex;
use std::{sync::Arc, time::Duration};

use super::single_retry;

Expand All @@ -52,7 +50,7 @@ mod tests {
let create_fut = || {
let call_count = call_count.clone();
async move {
let mut mutex_guard = call_count.lock().unwrap();
let mut mutex_guard = call_count.lock();
*mutex_guard += 1;
if *mutex_guard == 1 {
Err(())
Expand All @@ -64,7 +62,7 @@ mod tests {

let result = single_retry(create_fut, Duration::from_secs(10000)).await;

let guard = call_count.lock().unwrap();
let guard = call_count.lock();
assert_eq!(*guard, 2);
assert!(result.is_ok());
}
Expand All @@ -75,7 +73,7 @@ mod tests {
let create_fut = || {
let call_count = call_count.clone();
async move {
let mut mutex_guard = call_count.lock().unwrap();
let mut mutex_guard = call_count.lock();
*mutex_guard += 1;
if *mutex_guard == 1 {
Err::<(), _>(*mutex_guard)
Expand All @@ -87,7 +85,7 @@ mod tests {

let result = single_retry(create_fut, Duration::from_secs(10000)).await;

let guard = call_count.lock().unwrap();
let guard = call_count.lock();
assert_eq!(*guard, 2);
assert_eq!(result, Err(2));
}
Expand All @@ -99,7 +97,7 @@ mod tests {
let call_count = call_count.clone();
async move {
let call_count = {
let mut mutex_guard = call_count.lock().unwrap();
let mut mutex_guard = call_count.lock();
*mutex_guard += 1;
*mutex_guard
};
Expand All @@ -114,7 +112,7 @@ mod tests {

let result = single_retry(create_fut, Duration::from_millis(1)).await;

let guard = call_count.lock().unwrap();
let guard = call_count.lock();
assert_eq!(*guard, 2);
assert!(result.is_ok());
}
Expand All @@ -126,7 +124,7 @@ mod tests {
let call_count = call_count.clone();
async move {
let call_count = {
let mut mutex_guard = call_count.lock().unwrap();
let mut mutex_guard = call_count.lock();
*mutex_guard += 1;
*mutex_guard
};
Expand All @@ -140,7 +138,7 @@ mod tests {

let result = single_retry(create_fut, Duration::from_millis(1)).await;

let guard = call_count.lock().unwrap();
let guard = call_count.lock();
assert_eq!(*guard, 1);
assert!(result.is_ok());
}
Expand Down

0 comments on commit e6fcd8e

Please sign in to comment.