static void boot_resume_all(Restore& thing) { timestamps = thing.as_vector<uint64_t>(); thing.go_next(); // calculate time spent auto t1 = timestamps.back(); auto t2 = OS::nanos_since_boot(); // set final time timestamps.back() = t2 - t1; // retrieve binary blob #ifdef DRIFTING_BINARY blob_location = thing.as_type<char*>(); thing.go_next(); size_t len = thing.as_type<size_t> (); thing.go_next(); bloberino = buffer_t{blob_location, blob_location + len}; #else bloberino = thing.as_buffer(); thing.go_next(); #endif thing.pop_marker(); }
void IrcServer::deserialize(Restore& thing) { // we are re-entering this function, so store the counters statically chindex_t current_chan = 0; clindex_t current_client = 0; while (thing.is_end() == false) { switch (thing.get_id()) { case 1: { /// server size_t count; count = thing.as_type<size_t> (); thing.go_next(); for (size_t i = 0; i < count; i++) { auto fir = thing.as_string(); thing.go_next(); auto sec = thing.as_type<clindex_t> (); thing.go_next(); clients.hash(fir, sec); } count = thing.as_type<size_t> (); thing.go_next(); for (size_t i = 0; i < count; i++) { auto fir = thing.as_string(); thing.go_next(); auto sec = thing.as_type<chindex_t> (); thing.go_next(); channels.emplace_hash(fir, sec); } created_string = thing.as_string(); thing.go_next(); created_ts = thing.as_type<long> (); thing.go_next(); auto buf = thing.as_buffer(); thing.go_next(); if (buf.size() >= sizeof(statcounters)) { memcpy(statcounters, buf.data(), buf.size()); } //printf("* Resumed server, next id: %u\n", thing.get_id()); break; } case 20: /// channels // create free channel indices while (channels.size() < thing.as_type<chindex_t> ()) { channels.create_empty(*this); } thing.go_next(); { // create empty channel auto& ch = channels.create_empty(*this); // deserialize rest of channel ch.deserialize(thing); // go to next channel id current_chan++; } break; case 50: /// clients // create free client indices while (clients.size() < thing.as_type<clindex_t> ()) { clients.create_empty(*this); } thing.go_next(); { // create empty client auto& cl = clients.create_empty(*this); // deserialize rest of client cl.deserialize(thing); // assign event handlers for client cl.assign_socket_dg(); // go to next client id current_client++; } break; default: printf("Unknown ID: %u\n", thing.get_id()); thing.go_next(); break; } } // while (is_end() == false) }