xref: /third_party/rust/crates/once_cell/examples/reentrant_init_deadlocks.rs
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/rust/crates/once_cell/examples/
1ef40d7f6Sopenharmony_cifn main() {
2ef40d7f6Sopenharmony_ci    let cell = once_cell::sync::OnceCell::<u32>::new();
3ef40d7f6Sopenharmony_ci    cell.get_or_init(|| {
4ef40d7f6Sopenharmony_ci        cell.get_or_init(|| 1);
5ef40d7f6Sopenharmony_ci        2
6ef40d7f6Sopenharmony_ci    });
7ef40d7f6Sopenharmony_ci}
8ef40d7f6Sopenharmony_ci
9ef40d7f6Sopenharmony_ci/// Dummy test to make it seem hang when compiled as `--test`
10ef40d7f6Sopenharmony_ci/// See https://github.com/matklad/once_cell/issues/79
11ef40d7f6Sopenharmony_ci#[test]
12ef40d7f6Sopenharmony_cifn dummy_test() {
13ef40d7f6Sopenharmony_ci    std::thread::sleep(std::time::Duration::from_secs(4));
14ef40d7f6Sopenharmony_ci}
15

Indexes created Thu Nov 07 10:32:03 CST 2024