Skip to content

Commit 7b520ad

Browse files
committed
fix: Arc can be an Rc
In this case the value isn't shared across threads, hence it can be an `Rc` instead of an `Arc`.
1 parent 47d71fd commit 7b520ad

File tree

1 file changed

+5
-4
lines changed
  • storage-proofs-porep/src/stacked/vanilla/create_label

1 file changed

+5
-4
lines changed

storage-proofs-porep/src/stacked/vanilla/create_label/multi.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::convert::TryInto;
22
use std::marker::PhantomData;
33
use std::mem::{self, size_of};
44
use std::path::Path;
5+
use std::rc::Rc;
56
use std::sync::{
67
atomic::{AtomicU64, Ordering::SeqCst},
7-
Arc, MutexGuard,
8+
MutexGuard,
89
};
910
use std::thread;
1011
use std::time::Duration;
@@ -208,7 +209,7 @@ fn create_layer_labels(
208209
exp_labels: Option<&mut MmapMut>,
209210
num_nodes: u64,
210211
cur_layer: u32,
211-
core_group: Arc<Option<MutexGuard<'_, Vec<CoreIndex>>>>,
212+
core_group: Rc<Option<MutexGuard<'_, Vec<CoreIndex>>>>,
212213
) {
213214
info!("Creating labels for layer {}", cur_layer);
214215
// num_producers is the number of producer threads
@@ -458,7 +459,7 @@ pub fn create_labels_for_encoding<
458459

459460
let default_cache_size = DEGREE * 4 * cache_window_nodes;
460461

461-
let core_group = Arc::new(checkout_core_group());
462+
let core_group = Rc::new(checkout_core_group());
462463

463464
// When `_cleanup_handle` is dropped, the previous binding of thread will be restored.
464465
let _cleanup_handle = (*core_group).as_ref().map(|group| {
@@ -556,7 +557,7 @@ pub fn create_labels_for_decoding<Tree: 'static + MerkleTreeTrait, T: AsRef<[u8]
556557

557558
let default_cache_size = DEGREE * 4 * cache_window_nodes;
558559

559-
let core_group = Arc::new(checkout_core_group());
560+
let core_group = Rc::new(checkout_core_group());
560561

561562
// When `_cleanup_handle` is dropped, the previous binding of thread will be restored.
562563
let _cleanup_handle = (*core_group).as_ref().map(|group| {

0 commit comments

Comments
 (0)