Skip to content

Commit def9abc

Browse files
committed
more comments
1 parent 011746d commit def9abc

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/store/fs/bao_file.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
fs::{meta::raw_outboard_size, TaskContext},
3535
util::{
3636
read_checksummed_and_truncate, write_checksummed, FixedSize, MemOrFile,
37-
PartialMemStorage, SizeInfo, SparseMemFile, DD,
37+
PartialMemStorage, DD,
3838
},
3939
Hash, IROH_BLOCK_SIZE,
4040
},
@@ -531,13 +531,6 @@ impl BaoFileHandle {
531531
if Arc::strong_count(&self.0) > 1 {
532532
return false;
533533
}
534-
// there is the possibility that somebody else will increase the strong count
535-
// here. there is nothing we can do about it, but they won't be able to
536-
// access the internals of the handle because we have the lock.
537-
//
538-
// We poison the storage. A poisoned storage is considered dead and will
539-
// have to be recreated, but only *after* we are done with persisting
540-
// the bitfield.
541534
let BaoFileStorage::Partial(fs) = guard.take() else {
542535
return false;
543536
};
@@ -765,7 +758,7 @@ impl BaoFileHandle {
765758
}
766759

767760
impl PartialMemStorage {
768-
/// Persist the batch to disk, creating a FileBatch.
761+
/// Persist the batch to disk.
769762
fn persist(self, ctx: &TaskContext, hash: &Hash) -> io::Result<PartialFileStorage> {
770763
let options = &ctx.options.path;
771764
ctx.protect.protect(
@@ -793,12 +786,6 @@ impl PartialMemStorage {
793786
bitfield: self.bitfield,
794787
})
795788
}
796-
797-
/// Get the parts data, outboard and sizes
798-
#[allow(dead_code)]
799-
pub fn into_parts(self) -> (SparseMemFile, SparseMemFile, SizeInfo) {
800-
(self.data, self.outboard, self.size)
801-
}
802789
}
803790

804791
pub struct BaoFileStorageSubscriber {

src/store/fs/util/entity_manager.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ mod main_actor {
312312
impl<P: Params> EntityHandle<P> {
313313
pub fn send(&self) -> &mpsc::Sender<entity_actor::Command<P>> {
314314
match self {
315-
EntityHandle::Live { send: sender } => sender,
316-
EntityHandle::ShuttingDown { send: sender, .. } => sender,
315+
EntityHandle::Live { send } => send,
316+
EntityHandle::ShuttingDown { send, .. } => send,
317317
}
318318
}
319319
}
@@ -426,6 +426,9 @@ mod main_actor {
426426
task
427427
}
428428

429+
/// This function needs to be polled by the owner of the actor state to advance the
430+
/// entity manager state machine. If it returns a future, that future must be spawned
431+
/// by the caller.
429432
#[must_use = "this function may return a future that must be spawned by the caller"]
430433
pub async fn tick(&mut self) -> Option<impl Future<Output = ()> + Send + 'static> {
431434
if let Some(cmd) = self.internal_recv.recv().await {
@@ -492,6 +495,8 @@ mod main_actor {
492495
}
493496

494497
/// Get or create an entity actor for the given id.
498+
///
499+
/// If this function returns a future, it must be spawned by the caller.
495500
fn get_or_create(
496501
&mut self,
497502
id: P::EntityId,
@@ -501,14 +506,17 @@ mod main_actor {
501506
) {
502507
let mut task = None;
503508
let handle = self.live.entry(id.clone()).or_insert_with(|| {
504-
if let Some((sender, mut actor)) = self.pool.pop() {
509+
if let Some((send, mut actor)) = self.pool.pop() {
510+
// Get an actor from the pool of inactive actors and initialize it.
505511
actor.state.id = id.clone();
506512
actor.state.global = self.state.clone();
513+
// strictly speaking this is not needed, since we reset the state when adding the actor to the pool.
507514
actor.state.state.reset();
508515
task = Some(actor.run());
509-
EntityHandle::Live { send: sender }
516+
EntityHandle::Live { send }
510517
} else {
511-
let (sender, recv) = mpsc::channel(self.entity_inbox_size);
518+
// Create a new entity actor and inbox.
519+
let (send, recv) = mpsc::channel(self.entity_inbox_size);
512520
let state: entity_actor::State<P> = entity_actor::State {
513521
id: id.clone(),
514522
global: self.state.clone(),
@@ -523,7 +531,7 @@ mod main_actor {
523531
),
524532
};
525533
task = Some(actor.run());
526-
EntityHandle::Live { send: sender }
534+
EntityHandle::Live { send }
527535
}
528536
});
529537
(handle, task)

0 commit comments

Comments
 (0)