| 70 | } // namespace firewall { |
| 71 | |
| 72 | class ProcessBase : public EventConsumer |
| 73 | { |
| 74 | public: |
| 75 | explicit ProcessBase(const std::string& id = ""); |
| 76 | |
| 77 | ~ProcessBase() override; |
| 78 | |
| 79 | const UPID& self() const { return pid; } |
| 80 | |
| 81 | protected: |
| 82 | /** |
| 83 | * Invoked when an event is serviced. |
| 84 | */ |
| 85 | virtual void serve(Event&& event) |
| 86 | { |
| 87 | std::move(event).consume(this); |
| 88 | } |
| 89 | |
| 90 | // Callbacks used to consume (i.e., handle) a specific event. |
| 91 | void consume(MessageEvent&& event) override; |
| 92 | void consume(DispatchEvent&& event) override; |
| 93 | void consume(HttpEvent&& event) override; |
| 94 | void consume(ExitedEvent&& event) override; |
| 95 | void consume(TerminateEvent&& event) override; |
| 96 | |
| 97 | /** |
| 98 | * Invoked when a process gets spawned. |
| 99 | */ |
| 100 | virtual void initialize() {} |
| 101 | |
| 102 | /** |
| 103 | * Invoked when a process is terminated. |
| 104 | * |
| 105 | * **NOTE**: this does not get invoked automatically if |
| 106 | * `process::ProcessBase::consume(TerminateEvent&&)` is overridden. |
| 107 | */ |
| 108 | virtual void finalize() {} |
| 109 | |
| 110 | /** |
| 111 | * Invoked when a linked process has exited. |
| 112 | * |
| 113 | * For local linked processes (i.e., when the linker and linkee are |
| 114 | * part of the same OS process), this can be used to reliably detect |
| 115 | * when the linked process has exited. |
| 116 | * |
| 117 | * For remote linked processes, this indicates that the persistent |
| 118 | * TCP connection between the linker and the linkee has failed |
| 119 | * (e.g., linkee process died, a network error occurred). In this |
| 120 | * situation, the remote linkee process might still be running. |
| 121 | * |
| 122 | * @see process::ProcessBase::link |
| 123 | */ |
| 124 | virtual void exited(const UPID&) {} |
| 125 | |
| 126 | /** |
| 127 | * Invoked when a linked process can no longer be monitored. |
| 128 | * |
| 129 | * TODO(neilc): This is not implemented. |
nothing calls this directly
no test coverage detected