Comments (8)
I am not familar with the EventEmitter API. Can you provide a minimal self-containing runnable test class?
from haxe-concurrent.
Hi @sebthom this is a reproducible class, it works for small test
import buddy.Buddy;
using buddy.Should;
/**
@author Damilare Akinlaja
**/
class Main implements Buddy<[TestEvent]> {}
class TestEvent extends buddy.BuddySuite {
public function new() {
describe("Event emitter test", {
it("should emit only once", (done) -> {
final eventEmitter = new EventEmitter();
eventEmitter.once('start', (values) -> {
final start = values[0];
final end = values[1];
start.should.be(1);
end.should.be(100);
done();
});
eventEmitter.emit('start', 1, 100);
eventEmitter.emit('start', 2, 100);
});
});
}
}
But when I use it on a more bigger project and send many events, there is an obvious delay before listeners are triggered.
It fails entirely on C++ target with timeout errors Timeout after 5000 ms
in a more complex project with many events.
from haxe-concurrent.
Hi, the test works fine for me in CPP. But it fails for javascript. The reason seems to be your usage of the rest operator.
Testing with Javascript I get this error:
Event emitter test
should emit only once (FAILED)
Expected 100, was null
I guess the reason is your usage of the rest operator with the EventDispatcher#fire
method which only declares on argument.
In Javascript if you pass more arguments to a function than it declares, the remaining arguments are silently dropped by the JS runtime. Interestingly tho, it works on all targets except JavaScript, so maybe this is a bug in Haxe's JS transpiler in the context of generics, the haxe.Rest type and the rest operator.
from haxe-concurrent.
@sebthom noted! I'll fix that for JavaScript.
I still wonder why I get timeout errors in C++ in my project.
from haxe-concurrent.
Without having looked into your project. Maybe your are running into race conditions because of multi-threading. I don't think the way you are accessing the maps in the EventEmitter is thread-safe.
from haxe-concurrent.
@sebthom any idea how I can solve this problem?
from haxe-concurrent.
@sebthom any idea how I can solve this problem?
You could try to guard all calls to a map with a dedicated hx.concurrent.RLock instance.
from haxe-concurrent.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
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
- 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
- Specific code fails to port to HTML5, Flash HOT 3
- 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.