Skip to content

Commit

Permalink
Remove dependency on lazy static (#431)
Browse files Browse the repository at this point in the history
The gstreamer/webrtc crates were depending
on lazy_static, but not using it.

In the case of the streams crate, lazy_static
can be replaced by the LazyLock struct from
the standard library.
(https://doc.rust-lang.org/std/sync/struct.LazyLock.html)

Signed-off-by: Simon Wülker <[email protected]>
  • Loading branch information
simonwuelker authored Jan 19, 2025
1 parent 1ff6758 commit 4c24b9f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion backends/gstreamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ gst-webrtc = { workspace = true }
gst-sdp = { workspace = true }
gstreamer-sys = { workspace = true }
ipc-channel = { workspace = true }
lazy_static = "1.2.0"
log = "0.4"
mime = "0.3.13"
once_cell = "1.18.0"
Expand Down
1 change: 0 additions & 1 deletion streams/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ name = "servo_media_streams"
path = "lib.rs"

[dependencies]
lazy_static = "1.0"
uuid = { version = "1.4", features = ["v4"] }
3 changes: 0 additions & 3 deletions streams/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate lazy_static;

pub mod capture;
pub mod device_monitor;
pub mod registry;
Expand Down
11 changes: 6 additions & 5 deletions streams/registry.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use super::MediaStream;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::sync::{Arc, LazyLock, Mutex};
use uuid::Uuid;

lazy_static! {
static ref MEDIA_STREAMS_REGISTRY: Mutex<HashMap<MediaStreamId, Arc<Mutex<dyn MediaStream>>>> =
Mutex::new(HashMap::new());
}
type RegisteredMediaStream = Arc<Mutex<dyn MediaStream>>;

static MEDIA_STREAMS_REGISTRY: LazyLock<Mutex<HashMap<MediaStreamId, RegisteredMediaStream>>> = LazyLock::new(|| {
Mutex::new(HashMap::new())
});

#[derive(Clone, Copy, Hash, Eq, PartialEq)]
pub struct MediaStreamId(Uuid);
Expand Down
3 changes: 1 addition & 2 deletions webrtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ edition = "2021"
path = "lib.rs"

[dependencies]
lazy_static = "1.0"
log = "0.4.6"
log = "0.4"
uuid = { version = "1.4", features = ["v4"] }

[dependencies.servo-media-streams]
Expand Down

0 comments on commit 4c24b9f

Please sign in to comment.