jdonaldson / promhx

A promise and functional reactive programming library for Haxe
MIT License
145 stars 24 forks source link

Make EventLoop queueing thread safe on the JVM. #40

Closed vizanto closed 9 years ago

vizanto commented 9 years ago

Haxe's List class is not thread-safe.

Here's a sample stack trace of resolving a Deferred in a function called by haxe.Timer.delay:

java.lang.NullPointerException
    at haxe.root.List.pop(Unknown Source)
    at promhx.base.EventLoop_continueOnNextLoop_55__Fun.__hx_invoke0_o(Unknown Source)
    at promhx.base.EventLoop.continueOnNextLoop(Unknown Source)
    at promhx.base.AsyncBase._resolve(Unknown Source)
    at promhx.base.AsyncBase.handleResolve(Unknown Source)
    at promhx.Deferred.resolve(Unknown Source)

This change uses java.vm.AtomicList instead of List, but makes it impossible to implement queueLength without locking. Instead, I replaced it with queueEmpty.

jdonaldson commented 9 years ago

Thanks Danny!