| 41 | #include "flow/actorcompiler.h" // This must be the last #include. |
| 42 | |
| 43 | struct ExtMsg : IDispatched<ExtMsg, int32_t, std::function<ExtMsg*(ExtMsgHeader*, const uint8_t*)>>, |
| 44 | ReferenceCounted<ExtMsg> { |
| 45 | static Reference<ExtMsg> create(ExtMsgHeader* header, const uint8_t* body, Promise<Void> finished) { |
| 46 | Reference<ExtMsg> r(dispatch(header->opCode)(header, body)); |
| 47 | r->break_when_finished = finished; |
| 48 | return r; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * This promise will be broken only when this class is destructed, which triggers |
| 53 | * the release of the underlying memory |
| 54 | */ |
| 55 | Promise<Void> break_when_finished; |
| 56 | |
| 57 | virtual ~ExtMsg() = default; |
| 58 | |
| 59 | virtual std::string toString() = 0; |
| 60 | virtual Future<Void> run(Reference<ExtConnection>) = 0; |
| 61 | |
| 62 | template <class ExtMsgType> |
| 63 | struct Factory { |
| 64 | static ExtMsg* create(ExtMsgHeader* header, const uint8_t* body) { |
| 65 | return (ExtMsg*)(new ExtMsgType(header, body)); |
| 66 | } |
| 67 | }; |
| 68 | }; |
| 69 | |
| 70 | #define REGISTER_MSG(Msg) REGISTER_FACTORY(ExtMsg, Msg, opcode) |
| 71 |
nothing calls this directly
no outgoing calls
no test coverage detected