private void RemoveClient(int cookie, ClientIStorage stg) { if (m_client_storages.TryRemove(cookie, out _)) { // no responses come in from clients now Registry.UnregisterClient(stg.InstanceId); // no requests come in from servers now, safe to dispose stg.Dispose(); } }
private ClientIStorage AddValueFactory(int _) { ClientIStorage stg = new ClientIStorage(m_memorycloud) { Pulse = DateTime.Now }; int new_id = Registry.RegisterClient(stg); stg.InstanceId = new_id; return(stg); }
public override void RegisterClientHandler(RegisterClientRequestReader request, RegisterClientResponseWriter response) { response.PartitionCount = m_memorycloud.PartitionCount; var cstg = m_client_storages.AddOrUpdate(request.Cookie, _ => { ClientIStorage stg = new ClientIStorage(m_memorycloud); stg.Pulse = DateTime.Now; int new_id = Registry.RegisterClient(stg); stg.InstanceId = new_id; return(stg); }, (_, stg) => stg); response.InstanceId = cstg.InstanceId; }