MCPcopy Create free account
hub / github.com/actor-framework/actor-framework / detach

Method detach

libcaf_io/caf/io/network/manager.cpp:29–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void manager::detach(scheduler*, bool invoke_disconnect_message) {
30 auto lg = log::io::trace("invoke_disconnect_message = {}",
31 invoke_disconnect_message);
32 // This function gets called from the multiplexer when an error occurs or
33 // from the broker when closing this manager. In both cases, we need to make
34 // sure this manager does not receive further socket events.
35 remove_from_loop();
36 // Disconnect from the broker if not already detached.
37 if (!detached()) {
38 log::io::debug("disconnect servant from broker");
39 auto raw_ptr = parent();
40 // Keep a strong reference to our parent until we go out of scope.
41 strong_actor_ptr ptr;
42 ptr.swap(parent_);
43 detach_from(raw_ptr);
44 if (invoke_disconnect_message) {
45 auto mptr = make_mailbox_element(nullptr, make_message_id(),
46 detach_message());
47 switch (raw_ptr->consume(*mptr)) {
48 case invoke_message_result::consumed:
49 raw_ptr->finalize();
50 break;
51 case invoke_message_result::skipped:
52 raw_ptr->push_to_cache(std::move(mptr));
53 break;
54 case invoke_message_result::dropped:
55 log::io::info("broker dropped disconnect message");
56 break;
57 }
58 }
59 }
60}
61
62void manager::io_failure(scheduler* ctx, operation op) {
63 auto lg = log::io::trace("op = {}", op);

Callers

nothing calls this directly

Calls 11

traceFunction · 0.85
detachedFunction · 0.85
debugFunction · 0.85
make_message_idFunction · 0.85
finalizeMethod · 0.80
push_to_cacheMethod · 0.80
parentFunction · 0.50
make_mailbox_elementFunction · 0.50
infoFunction · 0.50
swapMethod · 0.45
consumeMethod · 0.45

Tested by

no test coverage detected