I have written an actor that is basically the consumer in an N:1 producer/consumer pattern. This actor holds a smart_ptr reference to an object that implements all the data sharing protocol stuff our customer wants. I also want this actor to be able to trigger a system-wide controlled shutdown if the protocol object receives a shutdown command.
#include "PublishActor.h"
PublishState::PublishState(PublishActor::pointer self, std::shared_ptr<CanPublish> publisher) :
self_(self),
publisher_(publisher) {}
PublishActor::behavior_type PublishState::make_behavior() {
publisher_->addShutdownListener(this);
self_->attach_functor([](const caf::error& reason) {
std::cout << "Publishing Actor shutting down: " + caf::to_string(reason) << std::endl;
});
return {
[this](do_publish) {
publisher_->publishData();
}
};
}
void PublishState::doShutdown() {
//self_->send_exit(self_, caf::exit_reason::user_shutdown);
self_->quit(caf::exit_reason::user_shutdown);
}
This actor is linked to another actor called "SupervisorActor" and all the other actors in my system are linked to Supervisor. My thinking is, if I can get PublishActor to shutdown then the linking will shutdown everything else as well.
Basically this works beautifully if PublisherActor uses self->send_exit(self) (see above). But if I use self->quit nothing shuts down (even itself). I was looking at the description of quit here, and it looked exactly like what I wanted:
I'm not overriding on_exit (unless attaching that functor does more than I think it does). What am I missing?