Comments (3)
HTLM and Flash targets are single threaded. So your loop
do {
trace(done.toString());
} while (!result.isComplete());
blocks any potential async execution.
Depending on the target platform a different Executor implementation is selected:
haxe-concurrent/src/hx/concurrent/executor/Executor.hx
Lines 33 to 39 in 4556ec0
For HTML/Flash it is the TimerExecutor which uses haxe.Timer
to schedule async execution of code. As long as you have actively running any code the execution of any scheduled async tasks is prevented.
To get true parallelism on the web one would need to use webworkers, however this has other consequences as they cannot access shared state but run in isolated processes.
from haxe-concurrent.
Out of curiosity, how can i wait or tell if all of the submissions in the TimerExecutor or ThreadPoolExecutor is completed? How would i fix the do while loop to not block any async execution?
from haxe-concurrent.
You need to get all your code after executor.submit(...)
out of the event loop to allow the browser/flash to do event processing.
This means you need to work with callbacks. Something like:
trace("waiting...");
var resultFuture = executor.submit(task);
result.onCompletion(result => {
// your code...
});
For HTML or Flash using the Executor will not improve performance as still only a single thread (the event loop) running on a single core is used. This is a target specific limitation. To do parallelism in Browser/HTML you could play around with webworkers but as I said this does not work with shared states and involves serialization/message passing.
from haxe-concurrent.
Related Issues (17)
- Right way to set the threads flag HOT 4
- Hashlink CG thread issue HOT 2
- Investigating Possible Memory Leak with Executor HOT 3
- How to ensure event is fired only Once! HOT 8
- haxe-concurrent doesn't work in android HOT 3
- Concurrent Map HOT 1
- "Virtual functions are pure" build error with RLock (HXCPP) HOT 4
- CPP abstract class error when building with Lime HOT 5
- Line ending issue in LICENSE.txt again HOT 1
- logs on startup HOT 4
- Thread Pool Spin Lock HOT 4
- [jvm] ExceptionInInitializerError HOT 9
- Error with latest Heapsio(hashlink target) and Haxe 4.0.0-rc2 HOT 1
- Package naming issue. HOT 2
- Example ? HOT 2
- Python 3.7 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 haxe-concurrent.