Skip to content
Snippets Groups Projects
Commit 3efb602a authored by Loïc Correnson's avatar Loïc Correnson
Browse files

Merge branch 'feature/ivette/persistent-state-values' into 'master'

[ivette] hold synchronized value in states

See merge request frama-c/frama-c!3751
parents 0c2299e1 02cd4983
No related branches found
No related tags found
No related merge requests found
......@@ -284,10 +284,11 @@ class SyncState<A> {
}
getValue(): A | undefined {
if (!this.upToDate && Server.isRunning()) {
const running = Server.isRunning();
if (!this.upToDate && running) {
this.update();
}
return this.value;
return running ? this.value : undefined;
}
async setValue(v: A): Promise<void> {
......@@ -309,18 +310,20 @@ class SyncState<A> {
async update(): Promise<void> {
try {
this.upToDate = true;
this.value = undefined;
this.UPDATE.emit();
if (Server.isRunning()) {
const v = await Server.send(this.handler.getter, null);
this.value = v;
this.UPDATE.emit();
} else if (this.value !== undefined) {
this.value = undefined;
this.UPDATE.emit();
}
} catch (error) {
D.error(
`Fail to update SyncState '${this.handler.name}'.`,
`${error}`,
);
this.value = undefined;
this.UPDATE.emit();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment