Created
August 19, 2015 11:08
-
-
Save alebianco/5a4ab56a6934bf3e2ed2 to your computer and use it in GitHub Desktop.
Promhx memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import promhx.Deferred; | |
import promhx.Stream; | |
import promhx.deferred.DeferredStream; | |
@:expose("game") | |
@:keep | |
class Main { | |
public static var instance:Main; | |
public var messages:Deferred<Int>; | |
public var stream:Stream<Int>; | |
public var handler:Stream<Void>; | |
public function new() { | |
messages = new Deferred<Int>(); | |
stream = messages.stream(); | |
} | |
public function attach():Void { | |
handler = stream.then(onMessage); | |
} | |
public function detach():Void { | |
stream.detachStream(handler); | |
// untyped stream._end_promise._update = []; | |
handler = null; | |
} | |
public function resolve(value:Int):Void { | |
messages.resolve(value); | |
} | |
public function loop(value:Int):Void { | |
attach(); | |
resolve(value); | |
detach(); | |
} | |
function onMessage(value:Int):Void { | |
trace(value); | |
} | |
static function main() { | |
instance = new Main(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment