chiark / gitweb /
break out PlayerUpdates.push nfc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 31 Jul 2020 21:31:41 +0000 (22:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 31 Jul 2020 21:31:41 +0000 (22:31 +0100)
src/updates.rs

index 367a838fe5ea0b8a0cde437db15d0a4e68b28e93..b33142d40e566f8365940ac6ca18bf876f8c3f20 100644 (file)
@@ -90,6 +90,13 @@ impl Default for PlayerUpdates {
   } }
 }
 
+impl PlayerUpdates {
+  fn push<U: Into<Arc<PreparedUpdate>>>(&mut self, update: U) {
+    self.log.push_back(update.into());
+    self.cv.notify_all();
+  }
+}
+
 impl PreparedUpdate {
   pub fn json_len(&self) -> usize {
     self.us.iter().map(|u| 20 + u.json_len()).sum()
@@ -266,8 +273,7 @@ impl<'r> Drop for PrepareUpdatesBuffer<'r> {
     eprintln!("UPDATE {:?}", &update);
 
     for (_tplayer, tplupdates) in &mut self.g.updates {
-      tplupdates.log.push_back(update.clone());
-      tplupdates.cv.notify_all();
+      tplupdates.push(update.clone());
     }
   }
 }