Comments (13)
Comment by hendrikebbers
Friday Feb 05, 2016 at 10:29 GMT
I don't know if we need a setting. Why not always check if we are in the Platform thread and otherwise do a invokeAndWait
from rico.
Comment by aalmiray
Friday Feb 05, 2016 at 10:42 GMT
Because JavaFX does not have an equivalent to invokeAndWait
. Well it does, but it's behind a private API that we shouldn't use
What we need is Platform.runLater
if not already inside the UI thread.
from rico.
Comment by hendrikebbers
Friday Feb 05, 2016 at 11:57 GMT
I don’t know if runLater is enough. Let’s say a property is set in a background thread. By doing so JFX property will be updated by invokeLater. But maybe the JFX property is bound bidirectional to more than 1 property. By doing so you can end in strange behavior. Example:
dpProperty1;
dpProperty2;
jfxProperty;
FXBinder.bind(jfxProperty).bidirectinalTo(dpProeprty1);
FXBinder.bind(jfxProperty).bidirectinalTo(dpProeprty1);
In external thread call:
dpProperty1.set(„Hello“);
dpProperty2.set(„World“);
System.out.print(dpProperty2);
By doing so the first line will call an update of the Property by using InvokeLater. Than the second one will be executed and again the update will be triggered by using invokeLater. Let’s say the first invokeLater is handled between line 2 and 3. By doing so line 3 will print „Hello“ instead of „World“. That’s why I would like to use a invokeAndWait. Creating this method for JFX is quite simple.
2 years ago I asked Richard Bair why invokeAndWait is not part of the public API. He told me that people that don’t know how to handle it will use it in a wrong / bad way but if you know how to handle it you can simply create it on your own. I think we are part of the second group and therefore should use it ;)
Am 05.02.2016 um 11:42 schrieb Andres Almiray [email protected]:
Because JavaFX does not have an equivalent to invokeAndWait. Well it does, but it's behind a private API that we shouldn't use
What we need is Platform.runLater if not already inside the UI thread.—
Reply to this email directly or view it on GitHub https://github.com/canoo/dolphin-platform/issues/77#issuecomment-180289702.
from rico.
Comment by netopyr
Friday Feb 05, 2016 at 12:37 GMT
I am afraid, I consider myself in the first group. ;)
Setting a property can cause change listeners to be fired. You have no idea and control over what happens in these listeners, thus wrapping property.set() in an invokeAndWait() seems like a bad idea.
from rico.
Comment by hendrikebbers
Friday Feb 05, 2016 at 12:51 GMT
@netopyr can you give a short example what could go wrong? Currently I see no problem and want to understand it
from rico.
Comment by netopyr
Friday Feb 05, 2016 at 13:23 GMT
If I understand your idea correctly, you want to wrap a call of the setter of a JavaFX property in an invokeAndWait-block, right? It is a JavaFX property, which means a user can attach any kind of change-listener to it. I could for example create a dead-lock by doing something that waits for the thread that called the setter in the first place.
As a rule of thumb I would never block anything, if I do not have full control over what is going to happen during the block and even if I have full control, I would try to avoid it.
from rico.
Comment by aalmiray
Friday Feb 05, 2016 at 14:12 GMT
No,no. This should be done with invokeLater
semantics, waiting would be overkill. Also, it only makes sense for now to protect the flow of data between DP property and JavaFX property, not the other way around, even in a bidirectional binding scenario.
from rico.
Comment by hendrikebbers
Friday Feb 05, 2016 at 14:13 GMT
Ok :)
from rico.
Comment by hendrikebbers
Friday Feb 05, 2016 at 14:15 GMT
Then this should be quite easy since we already have the UIThreadHandler instance in the config.
from rico.
Comment by hendrikebbers
Wednesday Feb 17, 2016 at 23:50 GMT
So the final plan is to call an invokeLater (by using UIThreadHandler) for setting the JFX property based on a change in the DP property, right?
from rico.
Comment by aalmiray
Thursday Feb 18, 2016 at 08:13 GMT
Yes, although I'd prefer a smarter version of invokeLater
:
- if already running inside UI thread -> execute
- else post event using
runLater
from rico.
Comment by netopyr
Thursday Feb 18, 2016 at 08:39 GMT
+1
The binding should behave synchronously if we are already on the right thread, because it makes it much easier to understand the simple case.
from rico.
Comment by hendrikebbers
Thursday Feb 18, 2016 at 10:38 GMT
ok
from rico.
Related Issues (20)
- clarify FIXME comment in TestClientConnectorImpl
- Rico version is not shown correctly in banner HOT 1
- Byte[] support in model by adding ConverterFactory implementation
- Adding . editorconfig file HOT 2
- External repository links for client library implementations in README are pointing to a wrong URL HOT 2
- Fix release build and version numbers
- Add git commit hash to MANIFEST.MF file. HOT 3
- Rico-Angular: Using multiple controllers duplicates model entries HOT 1
- Rico-Angular: Instanciating multiple controllers "at the same time" mixes up the model references HOT 4
- Rico-JS, Rico-Angular: Move functionality to Rico-JS.
- Security: NPE if user has no roles
- Better error handling in ClientSessionLifecycleHandlerImpl
- Double.NEGATIVE_INFINITY won't be transferred correctly by remoting
- Check old branches
- Check old Remoting branches
- apply new package structure to test packages
- SpringJUnitControllerTest is not using Junit 5 HOT 3
- JavaDoc is missing internal links
- Provide Hash-function for Download-Input Stream
- JavaDoc: @Param for generics produces warning 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 rico.