Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-Janggun committed Feb 26, 2024
1 parent e9611fe commit 65f15a3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions homework/scripts/grade-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ export -f run_linters
# NOTE: sanitizer documentation at https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html
cargo_asan() {
local SUBCOMMAND=$1; shift
local TARGET_TRIPLE=$(rustc -vV | sed -n 's|host: ||p')
RUSTFLAGS="-Z sanitizer=address" \
ASAN_OPTIONS="detect_leaks=1" \
RUSTDOCFLAGS="-Z sanitizer=address" \
cargo +nightly $SUBCOMMAND -Z build-std --target x86_64-unknown-linux-gnu "$@"
cargo +nightly $SUBCOMMAND -Z build-std --target $TARGET_TRIPLE "$@"
}
export -f cargo_asan

cargo_tsan() {
local SUBCOMMAND=$1; shift
local TARGET_TRIPLE=$(rustc -vV | sed -n 's|host: ||p')
RUSTFLAGS="-Z sanitizer=thread" \
TSAN_OPTIONS="suppressions=suppress_tsan.txt" \
RUSTDOCFLAGS="-Z sanitizer=thread" \
RUST_TEST_THREADS=1 \
cargo +nightly $SUBCOMMAND -Z build-std --target x86_64-unknown-linux-gnu "$@"
cargo +nightly $SUBCOMMAND -Z build-std --target $TARGET_TRIPLE "$@"
}
export -f cargo_tsan

Expand Down
4 changes: 2 additions & 2 deletions homework/src/hello_server/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl<K: Eq + Hash + Clone, V: Clone> Cache<K, V> {
/// `get_or_insert_with(key2, f2)` (`key1≠key2`, `key1,key2∉cache`) concurrently, `f1` and `f2`
/// should run concurrently.
///
/// On the other hand, since `f` may consume a lot of resource (= money), it's desirable not to
/// On the other hand, since `f` may consume a lot of resource (= money), it's undesirable to
/// duplicate the work. That is, `f` should be run only once for each key. Specifically, even
/// for the concurrent invocations of `get_or_insert_with(key, f)`, `f` is called only once.
/// for concurrent invocations of `get_or_insert_with(key, f)`, `f` is called only once per key.
///
/// Hint: the [`Entry`] API may be useful in implementing this function.
///
Expand Down
3 changes: 2 additions & 1 deletion homework/src/list_set/fine_grained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ unsafe impl<T: Send> Sync for FineGrainedListSet<T> {}
/// ```
///
/// If `cursor` is currently at node 2, then `cursor.0` should be the `MutexGuard` obtained from the
/// `next` of node 1. In particular, `cursor.0.as_ref().unwrap()` creates a shared reference to node 2.
/// `next` of node 1. In particular, `cursor.0.as_ref().unwrap()` creates a shared reference to node
/// 2.
struct Cursor<'l, T>(MutexGuard<'l, *mut Node<T>>);

impl<T> Node<T> {
Expand Down
6 changes: 3 additions & 3 deletions homework/tests/growable_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod stack {
use core::ops::Deref;
use core::ptr;
use core::sync::atomic::Ordering::*;
use crossbeam_epoch::{Atomic, Guard, Shared};
use crossbeam_epoch::{Atomic, Guard, Owned, Shared};

#[derive(Debug)]
pub(crate) struct Stack<T> {
Expand Down Expand Up @@ -147,8 +147,8 @@ mod stack {
fn drop(&mut self) {
let mut o_curr = mem::take(&mut self.head);

while let Some(curr) = unsafe { o_curr.try_into_owned() } {
o_curr = curr.into_box().next.into_inner().into();
while let Some(curr) = unsafe { o_curr.try_into_owned() }.map(Owned::into_box) {
o_curr = curr.next.into_inner().into();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lockfree/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ where
#[inline]
pub fn insert(
&mut self,
node: Owned<Node<K, V>>,
mut node: Owned<Node<K, V>>,
guard: &'g Guard,
) -> Result<(), Owned<Node<K, V>>> {
node.next.store(self.curr, Relaxed);
node.next = self.curr.into();
match self
.prev
.compare_exchange(self.curr, node, Release, Relaxed, guard)
Expand Down

0 comments on commit 65f15a3

Please sign in to comment.