Move operation serialization off the main thread

This commit is contained in:
Antonio Scandurra 2022-08-23 16:34:25 +02:00
parent 954695f5fe
commit f0d35ccc50
5 changed files with 57 additions and 39 deletions

View file

@ -5693,11 +5693,15 @@ impl Project {
if let Some(project_id) = self.remote_id() {
let shared_buffers = self.shared_buffers.entry(peer_id).or_default();
if shared_buffers.insert(buffer_id) {
let (state, mut operations) = buffer.read(cx).to_proto();
let buffer = buffer.read(cx);
let state = buffer.to_proto();
let operations = buffer.serialize_ops(cx);
let client = self.client.clone();
cx.background()
.spawn(
async move {
let mut operations = operations.await;
client.send(proto::CreateBufferForPeer {
project_id,
peer_id: peer_id.0,