forked from ringo/ringojs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ringo#238 from pykl/workerpromise
syncCallbacks property for WorkerPromise
- Loading branch information
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var log = require( 'ringo/logging' ).getLogger( module.id ); | ||
/** | ||
* The worker module needed by promise_test | ||
*/ | ||
function onmessage(e) { | ||
|
||
var source = e.source; | ||
var result = e.data.result || { success: true }; | ||
var delay = e.data.delay || 2000; | ||
|
||
var success = function() { | ||
log.info( 'Posting the result: ', JSON.stringify( result ) ); | ||
source.postMessage( result ); | ||
}; | ||
|
||
setTimeout( success, delay ); | ||
} |