| 2064 | } |
| 2065 | |
| 2066 | void DatastoreSourceWriteHost::setSecondaryEngine(DataEngine* secondary) { |
| 2067 | // Wire the secondary engine for streaming pause/resume lockstep. Mirroring |
| 2068 | // is bidirectional: the active WriteCore mirrors to whichever engine is |
| 2069 | // the other one. Called once by the streaming runtime host right after |
| 2070 | // construction; passing nullptr disables mirroring. |
| 2071 | state_->secondary_engine = secondary; |
| 2072 | // Called once right after construction, before any ingest worker runs, so |
| 2073 | // mutating the live core's mirror target in place is safe (no concurrent reader |
| 2074 | // yet); load() merely unwraps the atomic. |
| 2075 | if (auto core = state_->core.load(std::memory_order_acquire)) { |
| 2076 | // Whichever direction we're currently pointed at, mirror to the other. |
| 2077 | core->secondary_engine = (&core->engine == state_->primary_engine) ? secondary : state_->primary_engine; |
| 2078 | } |
| 2079 | } |
| 2080 | |
| 2081 | DatastoreParserWriteHost::DatastoreParserWriteHost(DataEngine& engine, TopicHandle topic) |
| 2082 | : state_(std::make_unique<DatastoreParserWriteHostState>(engine, topic)) {} |