Comments (3)
If I understand the problem correctly, invokeAndWait gives all listeners a chance to change the system state before the rest of the processing in handleOneIncomingReply() by invoking them on the UI thread in a Runnable.
However, I don't see what state can be changed by a listener that changes how handleOneIncomingReply completes its processing. I am also under the impression that the Runnable passed in invokeLater(Runnable) is guaranteed to be run in the order in which Runnables were queued by invokeLater(Runnable). So if listeners notified by the Runnable can't change how handleOneIncomingReply processes its data, and are guaranteed to be notified in packet order, what does the invokeAndWait buy us that invokeLater does not?
I think it buys us the ability to ensure all state is changed before the next reply is read, but don't know if that's a good thing or not.
from jmri.
I'll use C/MRI as an example. There are three threads running: line transmit (xmt for short), line receive (rcv) and Swing/AWT (AWT).
When the end of an incoming message is reached, the rcv thread drops through loadChars at AbstractTrafficController (ATC) line 852, notifies everybody of the response which processes inputs which can in turn generate output requests (see below). It then looks at the state, and in normal operation does a notify() of the xmt thread.
For C/MRI, the notify()ed xmt thread then runs the pollMessage() routine that goes through checking if nodes need to be initialized, if nodes have output that should be sent, and finally if any nodes need to be polled. It sends the 1st thing that scan finds.
invokeAndWait ensures that any output that's been generated by a poll response will go out right away. InvokeLater ensures that it won't. (The AWT/Swing events happen in the same order, because invokeLater and invokeAndWait invoke at the same point in the queue; they only differ in whether the posting thread waits)
Is that a problem? I don't know. I'm pretty sure that it wasn't thought through when that code was originally written. I don't think the "synchronized" attributes were checked with that in mind. Maybe it's fine. But I don't know that it is.
from jmri.
@pabender @bobjacobsen Thanks for the explanations here and in #422.
I'm thinking this problem can be safely ignored unless someone thinks they get a performance boost out of testing if InvokeLater() works for a specific system. I'm thinking that without physical access to a real system, changes will be hard to test.
from jmri.
Related Issues (20)
- Dispatch with JMRI Throttle to FRED(I) doesn't work (ex-#9607 - closed) HOT 7
- Create Test Release 5.3.8 HOT 2
- Default Preferences are Invalid HOT 13
- Zoomed CPE panels slow to display changed Memory contents HOT 1
- Create Test Release 5.5.1 HOT 2
- Can't add Fast Clock to Control Panel Editor panel HOT 1
- Connect JMRI on MAC with Apple processor to DCS 240 using USB HOT 13
- 45227
- Analog clock does not show when halted HOT 2
- Analog fast clock shows un-prototypic images HOT 2
- Analog fast clock could use an optional AM/PM indicator HOT 1
- Create Production Release 5.4 HOT 3
- Create Test Release 5.5.2 HOT 3
- Zimo MS+MN-Decoders CV115 is missing in "Shunt/Uncouple" HOT 6
- Layout Editor Shapes cause Java Exception HOT 3
- Add web panel support for positionableRoundRect HOT 1
- Setting up trains in dispatcher system HOT 1
- Throttle Window Does Not Resize Correctly
- [Feature Request] Reporter appearance on Layout Editor Panel HOT 5
- Hornby HM700 Decoder Support HOT 1
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 jmri.