Skip to content

Commit 7004669

Browse files
committed
Replace parking_lot with std::sync types
As of rust-lang/rust#95035, the locking API provided by std::sync is improved on Linux, outperforming parking_lot in various cases. Using the built-in locking APIs means we can remove parking_lot as a dependency, along with its own (indirect) dependencies; removing a total of 10 dependencies.
1 parent a49c7fb commit 7004669

File tree

6 files changed

+44
-128
lines changed

6 files changed

+44
-128
lines changed

Cargo.lock

Lines changed: 2 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ libffi-system = ["libffi/system"]
1414

1515
[dependencies]
1616
num_cpus = "^1.13"
17-
parking_lot = "^0.12"
1817

1918
# Newer versions of the `time` crate only expose local time behind a
2019
# compile-time --cfg flag. This isn't viable for us, as it makes the compilation

vm/src/permanent_space.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use crate::mem::{
77
};
88
use crate::process::Future;
99
use ahash::AHashMap;
10-
use parking_lot::Mutex;
1110
use std::mem::size_of;
1211
use std::ops::Drop;
12+
use std::sync::Mutex;
1313

1414
pub(crate) const INT_CLASS: usize = 0;
1515
pub(crate) const FLOAT_CLASS: usize = 1;
@@ -169,7 +169,7 @@ impl PermanentSpace {
169169
/// If an Inko String has already been allocated for the given Rust String,
170170
/// the existing Inko String is returned; otherwise a new one is created.
171171
pub(crate) fn allocate_string(&self, string: String) -> Pointer {
172-
let mut strings = self.interned_strings.lock();
172+
let mut strings = self.interned_strings.lock().unwrap();
173173

174174
if let Some(ptr) = strings.get(&string) {
175175
return *ptr;
@@ -190,15 +190,15 @@ impl PermanentSpace {
190190
} else {
191191
let ptr = ptr.as_permanent();
192192

193-
self.permanent_objects.lock().push(ptr);
193+
self.permanent_objects.lock().unwrap().push(ptr);
194194
ptr
195195
}
196196
}
197197

198198
pub(crate) fn allocate_float(&self, value: f64) -> Pointer {
199199
let ptr = Float::alloc(self.float_class(), value).as_permanent();
200200

201-
self.permanent_objects.lock().push(ptr);
201+
self.permanent_objects.lock().unwrap().push(ptr);
202202
ptr
203203
}
204204

@@ -290,11 +290,11 @@ impl PermanentSpace {
290290
impl Drop for PermanentSpace {
291291
fn drop(&mut self) {
292292
unsafe {
293-
for pointer in self.interned_strings.lock().values() {
293+
for pointer in self.interned_strings.lock().unwrap().values() {
294294
InkoString::drop_and_deallocate(*pointer);
295295
}
296296

297-
for ptr in self.permanent_objects.lock().iter() {
297+
for ptr in self.permanent_objects.lock().unwrap().iter() {
298298
ptr.free();
299299
}
300300

0 commit comments

Comments
 (0)