Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Simultaneous timer events #176

Open
mode89 opened this issue Mar 26, 2022 · 4 comments
Open

Simultaneous timer events #176

mode89 opened this issue Mar 26, 2022 · 4 comments

Comments

@mode89
Copy link

mode89 commented Mar 26, 2022

Hi :)

If I understand it correctly, for each timer event current Java implementation generates a separate transaction, inside send(). What if there are multiple events scheduled to the same point in time? Shouldn't their send()s, as well as TimerSystem.time.send(), be aggregated into a single transaction in order to guarantee coalescence?

@mode89
Copy link
Author

mode89 commented Mar 30, 2022

Here is a test:

TimerSystem ts = new MillisecondsTimerSystem();
Cell<Long> time = ts.time;
List<Long> out = new ArrayList<>();
Transaction.runVoid(() -> {
    Long now = time.sample();
    Stream a1 = ts.at(new Cell(Optional.of(now + 100)));
    Stream a2 = ts.at(new Cell(Optional.of(now + 100)));
    Stream<Long> m = a1.orElse(a2);
    m.listen((Long t) -> {
        out.add(t);
    });
});
try { Thread.sleep(200); } catch (InterruptedException e) {}
assertEquals(1, out.size());

It starts two alarms that should trigger at the same point in time. The stream, produced by merging both alarms, should have only one event.

@jam40jeff
Copy link
Contributor

Thanks for the test. I have fixed this in the C# and F# versions (but not pushed yet) and will try to take a look at the Java version soon.

@mode89
Copy link
Author

mode89 commented Jan 9, 2023

Thanks :)

@jam40jeff jam40jeff reopened this Apr 23, 2023
@jam40jeff
Copy link
Contributor

This has been fixed in the C# and F# versions. I will leave it open until the Java version is fixed as well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants