mirror of
https://github.com/facebookexperimental/reverie.git
synced 2025-01-23 13:10:04 +00:00
03cbd6044d
Summary: Followed guide here https://www.internalfb.com/intern/wiki/Linting/License_Lint/ to add fbcode/hermetic_infra/** code to license linter. As we have parts of our code shipped as Open Source it's important to get this automated This diff is updating existing file's licenses to not get conflict after lint rule enablement Reviewed By: jasonwhite Differential Revision: D40674080 fbshipit-source-id: da6ecac036f8964619cf7912058f3a911558e7b1
53 lines
1.4 KiB
Rust
53 lines
1.4 KiB
Rust
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
use reverie::Tool;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
|
struct LocalState;
|
|
|
|
#[reverie::tool]
|
|
impl Tool for LocalState {}
|
|
|
|
#[cfg(all(not(sanitized), test))]
|
|
mod tests {
|
|
use std::sync::atomic::AtomicUsize;
|
|
use std::sync::atomic::Ordering;
|
|
use std::sync::Arc;
|
|
use std::thread;
|
|
use std::time;
|
|
|
|
use reverie_ptrace::testing::check_fn;
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn run_guest_spinlock_test() {
|
|
check_fn::<LocalState, _>(move || {
|
|
let lock = Arc::new(AtomicUsize::new(0));
|
|
let mut handles: Vec<_> = (0..10)
|
|
.map(|_| {
|
|
let lock = lock.clone();
|
|
thread::spawn(move || while lock.load(Ordering::Acquire) != 10 {})
|
|
})
|
|
.collect();
|
|
handles.push(thread::spawn(move || {
|
|
for _ in 0..10 {
|
|
lock.fetch_add(1, Ordering::Release);
|
|
let dur = time::Duration::from_millis(10);
|
|
thread::sleep(dur);
|
|
}
|
|
}));
|
|
for h in handles {
|
|
let _ = h.join();
|
|
}
|
|
});
|
|
}
|
|
}
|