mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-09 17:34:08 +00:00
feat: fix sync var
This commit is contained in:
parent
c0c580090e
commit
a794bd3af4
@ -55,11 +55,12 @@ public class SharableVarManager {
|
||||
String type = message.header.parameters.attributes.get("type").getAsString();
|
||||
SharableVar var = allVars.get(varId);
|
||||
if (var != null) {
|
||||
JoinableCRDT delta = JsonUtil.fromJson(content, JoinableCRDT.class);
|
||||
if (Objects.equals(type, "r2r") || Objects.equals(type, "w2r")) {
|
||||
JoinableCRDT delta = JsonUtil.fromJson(content, var.readerVar.getClass());
|
||||
var.readerVar.join(delta);
|
||||
var.readerVarDeltaQueue.add(delta);
|
||||
} else if (Objects.equals(type, "w2w")) {
|
||||
JoinableCRDT delta = JsonUtil.fromJson(content, var.writerVar.getClass());
|
||||
var.writerVar.join(delta);
|
||||
var.writerVarDeltaQueue.add(delta);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ public abstract class SharableVar<T extends JoinableCRDT> {
|
||||
this.readerTimer.newTimeout(timeout -> {
|
||||
readerSyncTimerTask = new ReaderSyncTimerTask();
|
||||
readerTimer.newTimeout(readerSyncTimerTask, sharableVarState.getReaderInterval(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
}, 0, TimeUnit.MILLISECONDS);
|
||||
TimeUnit.SECONDS);
|
||||
}, this.sharableVarState.getReaderInterval(), TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
if (this.sharableVarState.isWriterFlag()) {
|
||||
@ -65,8 +65,8 @@ public abstract class SharableVar<T extends JoinableCRDT> {
|
||||
this.writerTimer.newTimeout(timeout -> {
|
||||
writerSyncTimerTask = new WriterSyncTimerTask();
|
||||
writerTimer.newTimeout(writerSyncTimerTask, sharableVarState.getWriteInterval(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
}, 0, TimeUnit.MILLISECONDS);
|
||||
TimeUnit.SECONDS);
|
||||
}, this.sharableVarState.getWriteInterval(), TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,7 @@ public abstract class SharableVar<T extends JoinableCRDT> {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
readerTimer.newTimeout(readerSyncTimerTask, sharableVarState.getReaderInterval(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,8 +132,8 @@ public abstract class SharableVar<T extends JoinableCRDT> {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
readerTimer.newTimeout(writerSyncTimerTask, sharableVarState.getWriteInterval(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
writerTimer.newTimeout(writerSyncTimerTask, sharableVarState.getWriteInterval(),
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user