mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Improve client connection synchronization behavior.
The original synchronization behavior was troublesome for two reasons: - It had unpredictable behavior for updated values - It brought back to life deleted values Instead of relying on the server to inform the client regarding reconnections, the client keeps track of what values have been modified by user code on the client. When the client connects to the server, the following occurs. For entries that have been modified by user code on the client: - If the entry is not persistent, the server value is overwritten with the client value - If the entry does not exist on the server, the client sends an assignment to the server to recreate it on the server For entries that have not been modified by user code on the client: - The client value is overwritten with the server value - If the entry does not exist on the server, the client deletes the entry Fixes #8.
This commit is contained in:
@@ -156,6 +156,10 @@ class Storage : public IStorage {
|
||||
// Sequence number for update resolution.
|
||||
SequenceNumber seq_num;
|
||||
|
||||
// If value has been written locally. Used during initial handshake
|
||||
// on client to determine whether or not to accept remote changes.
|
||||
bool local_write{false};
|
||||
|
||||
// RPC handle.
|
||||
unsigned int rpc_uid{UINT_MAX};
|
||||
|
||||
@@ -220,6 +224,8 @@ class Storage : public IStorage {
|
||||
std::unique_lock<std::mutex>& lock, bool local);
|
||||
|
||||
// Must be called with m_mutex held
|
||||
template <typename F>
|
||||
void DeleteAllEntriesImpl(bool local, F should_delete);
|
||||
void DeleteAllEntriesImpl(bool local);
|
||||
Entry* GetOrNew(StringRef name, bool* is_new = nullptr);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user