Huy's Notes
Notes on Actix ActorFuture

Notes on Actix ActorFuture

#rust, #actix, #actor-model

First, ActorFuture is Actix's version of future, it's not the traditional futures.

We run the ActorFuture by calling the wait method of its Context. This method will block the message stream, to prevent any further messages being processed until the current Message is finished processing.

I stumped upon a case where I need to send multiple messages in sequence, this kind of task can be done by using a normal future:

let fut = async move {

And then, convert the future into ActorFuture (because we need to use wait method), by doing either:

let run = fut.into_actor(self);


let run = actix::fut::wrap_future::<_, Self>(fut);

After that, we can consume the ActorFuture just like how we do it for single message cases:|result, actor, context} { ... }).wait(ctx);

Referred in

If you think this note resonated, be it positive or negative, please feel free to send me an email and we can talk.