Skip to content

Commit

Permalink
Added comment and made ActorState pub(crate) (#3944)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton authored Oct 12, 2023
1 parent 58fc5ab commit a99dfd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions quickwit/quickwit-actors/src/actor_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ActorState {
}
}

pub struct AtomicState(AtomicU32);
pub(crate) struct AtomicState(AtomicU32);

impl Default for AtomicState {
fn default() -> Self {
Expand All @@ -80,7 +80,7 @@ impl Default for AtomicState {
}

impl AtomicState {
pub fn process(&self) {
pub(crate) fn process(&self) {
let _ = self.0.compare_exchange(
ActorState::Idle as u32,
ActorState::Processing as u32,
Expand All @@ -89,7 +89,7 @@ impl AtomicState {
);
}

pub fn idle(&self) {
pub(crate) fn idle(&self) {
let _ = self.0.compare_exchange(
ActorState::Processing as u32,
ActorState::Idle as u32,
Expand All @@ -98,7 +98,7 @@ impl AtomicState {
);
}

pub fn pause(&self) {
pub(crate) fn pause(&self) {
let _ = self
.0
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| {
Expand All @@ -109,7 +109,7 @@ impl AtomicState {
});
}

pub fn resume(&self) {
pub(crate) fn resume(&self) {
let _ = self.0.compare_exchange(
ActorState::Paused as u32,
ActorState::Processing as u32,
Expand Down
8 changes: 7 additions & 1 deletion quickwit/quickwit-actors/src/spawn_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ impl<A: Actor + Default> SpawnBuilder<A> {
}
}

/// Returns `None` if no message is available at the moment.
/// Receives an envelope from either the high priority queue or the low priority queue.
///
/// In the paused state, the actor will only attempt to receive high priority messages.
///
/// If no message is available, this function will yield until a message arrives.
/// If a high priority message is arrives first it is guaranteed to be processed first.
/// This other way around is however not guaranteed.
async fn recv_envelope<A: Actor>(inbox: &mut Inbox<A>, ctx: &ActorContext<A>) -> Envelope<A> {
if ctx.state().is_running() {
ctx.protect_future(inbox.recv()).await.expect(
Expand Down

0 comments on commit a99dfd9

Please sign in to comment.