Comments (6)
The current rule is that loopFinished is called exactly once and then close is called exactly once on an event handler when it is either removed from an event loop, or the event loop is stopped.
Please review EventGroupTest - this enforces this contract.
It needs to be better documented - will do so tomorrow.
from chronicle-threads.
Ok. What is the rationale of having two different methods being invoked on the same event?
loopFinished() {
a();
}
close() {
b()
}
But instead we might as well just have:
close() {
a();
b();
}
from chronicle-threads.
@minborg there is some history here - OpenHFT/Chronicle-Network#45
In a nutshell, you can't rely on close() to release resources because the action method may still be executing in another thread.
We could make a rule that if an EventHandler implements Closeable then it is only allowed to be called by the event loop? Then we could do away with loopFinished.
from chronicle-threads.
In general, we should have a consistent life-cycle for both the EventLoop
and EventHandler
. Either an EventHandler
is managed by an EventLoop
or by its creating entity. This is of particular importance in this case because of thread visibility issues.
Letting the EventLoop
invoke close()
creates a dissonance in my opinion as the EventHandler
is created by another entity using another thread but then handed over to the EventLoop
. Either the creating entity should invoke close()
or the EventLoop
should create the EventHandler
, potentially via a provided Supplier<EventHandler>
.
I think it would be more consistent to let the creating entity manage the lifecycle of the EventHandler
and remove the magic invocation of close()
and instead have:
- onAdded()
- onRemoved()
which are invoked exactly one time by the EventLoop
(using.the event loop's thread). These methods can then be used to initialize and clean up the EventHandler
with no concurrency issues.
from chronicle-threads.
The behaviour for closeable is that should expect to be called one or more times and ignore any duplicates. SimpleCloseable
can assist.
from chronicle-threads.
Released in Chronicle-Threads-2.20.43, BOM-2.20.67
from chronicle-threads.
Related Issues (20)
- Update figure 1 in ReadMe.adoc to the Chronicle infographic style
- False positive monitorThreadDelayed reports on almost-idle thread HOT 2
- flaky test VanillaEventLoopTest.testEnsureRemoveInvokesLoopFinishedJustOnce HOT 2
- Make image background navy
- When EventGroup startup times out, provide more information about the state of the EventLoops HOT 1
- Add a systemProperties.adoc with a table of system properties (if there are any) HOT 1
- Tuning LongPauser to be less platform sensitive
- Add paragraph to adoc about Chronicle Threads
- Add to Pauser documentation
- Add pauser graph to documentation HOT 1
- MediumEventLoop silently terminates when an IllegalStateException is thrown on startup HOT 1
- The contract for EventHandler#loopFinished is violated a lot HOT 4
- Add Information to ReadMe from landing page
- Data race between handler.eventLoop(EventLoop) and first handler execution HOT 1
- Add support for collecting the current EventLoops and their Pausers HOT 1
- EventGroup sometimes times out on start HOT 5
- Blocking loop runs jobs before event group is alive HOT 3
- EventGroupStressTest is flaky HOT 1
- NoSuchFieldException JDK 20 HOT 3
- Detect if event loop is being closed from its own thread HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chronicle-threads.