Permalink
Browse files

Merge remote-tracking branch 'ack/develop' into develop_issue_21

  • Loading branch information...
2 parents ec6524d + 8f36cb9 commit 5b4403a162b4058bae1ef2aae5518c7fba7f2eed @northWind87 committed Dec 1, 2011
Showing with 31 additions and 11 deletions.
  1. +6 −0 example/simple/index.html
  2. +13 −0 example/simple/simple.js
  3. +8 −7 src/core/threading/proxy.js
  4. +4 −4 src/core/threading/thread.js
@@ -0,0 +1,6 @@
+<html>
+ <head>
+ <script src="../../dist/gladius.min.js"></script>
+ <script src="simple.js"></script>
+ </head>
+</html>
View
@@ -0,0 +1,13 @@
+var game = function( engine ) {
+ // Create a new task to log the frame count
+ var t = new engine.scheduler.Task({
+ callback: function() {
+ console.log( engine.scheduler.frame );
+ }
+ });
+
+ // Start the engine!
+ engine.run();
+};
+
+gladius.create( {debug: true}, game );
@@ -5,7 +5,7 @@
define( function( require ) {
var lang = require( '../lang' );
- var Thread = require( './thread' );
+ var thread = require( './thread' );
var Proxy = function( options ) {
@@ -23,8 +23,8 @@ define( function( require ) {
var that = this;
var _script = new BlobBuilder();
- _script.append( Thread.toString() );
- _script.append( '__thread(\'' + _id + '\');' );
+ _script.append( 'var f = ' + thread.toString() + ';' );
+ _script.append( 'f(\'' + _id + '\');' );
var _scriptUrl = window.URL.createObjectURL( _script.getBlob() );
var _worker = new Worker( _scriptUrl );
@@ -49,6 +49,7 @@ define( function( require ) {
if( _exposed[ message.method ] ) {
_exposed[ message.method ]( message.request );
} else {
+ console.log( Object.keys( _exposed ) );
console.log( 'ignoring unknown method ' + message.method + ' from worker' );
}
};
@@ -62,21 +63,21 @@ define( function( require ) {
}
_request = null;
};
- expose( handle_result );
+ expose( handle_result, '__result' );
var handle_ready = function __ready() {
_ready( that );
};
- expose( handle_ready );
+ expose( handle_ready, '__ready' );
var handle_error = function __error( message ) {
};
- expose( handle_error );
+ expose( handle_error, '__error' );
var handle_log = function __log( message ) {
console.log( '[thread:' + _id + '] ' + message.log );
};
- expose( handle_log );
+ expose( handle_log, '__log' );
this.dispatch = function( options ) {
options = options || {};
@@ -4,7 +4,7 @@
define( function( require ) {
- var Thread = function __thread( id ) {
+ var thread = function __thread( id ) {
var console = {
@@ -61,17 +61,17 @@ define( function( require ) {
});
send( '__ready' );
};
- expose( handle_dispatch );
+ expose( handle_dispatch, '__dispatch' );
var handle_run = function __run( message ) {
_id = message.id;
};
- expose( handle_run );
+ expose( handle_run, '__run' );
send( '__ready' );
};
- return Thread;
+ return thread;
});

0 comments on commit 5b4403a

Please sign in to comment.