Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WAKSystemWorkerProxy

Hierarchy

  • WAKSystemWorkerProxy

Index

Properties

onerror

onerror: function

Callback for system worker errors.

// Receives an error
workerProxy.onerror = function ( event ) {
    console.log( event.type +': '+ event.data );
}

Type declaration

onmessage

onmessage: function

Callback for system worker messages. The message can be sent into multiple chunks.

// Receives a message chunck
workerProxy.onmessage = function ( event ) {
    console.log( event.type +': '+ event.data );
}

Type declaration

onterminated

onterminated: function

Callback when the external process is terminating.

// Receives an "end" event from system worker
workerProxy.onterminated = function ( event ) {
    console.log( event.type +': with exitStatus:'+ event.exitStatus );
}

Type declaration

Methods

endOfInput

  • endOfInput(): void
  • Closes the input stream (stdin) of the external process. Useful when an attempt to write in the stdin of the external process with postMessage() is stuck. endOfInput() will release the execution.

    // Create some data to gzip
    var input = new Buffer( 'abcde', 'ascii' );
    // Create an asynchronous system worker
    var worker = new SystemWorker( 'gzip' );
    // Send the compressed file on stdin.
    worker.postMessage( input );
    // Note that we call endOfInput() to indicate we're done. gzip (and most program waiting data from stdin) will wait for more data until the input is explicitely closed.
    worker.endOfInput();

    Returns void

getInfos

  • getInfos(): Object

postMessage

  • Write on the input stream (stdin) of the external process.

    // Create an asynchronous system worker
    var worker = new SystemWorker( 'gzip' );
    // Send the compressed file on stdin.
    worker.postMessage( 'abcde' );
    // Note that we call endOfInput() to indicate we're done. gzip (and most program waiting data from stdin) will wait for more data until the input is explicitely closed.
    worker.endOfInput();

    Parameters

    • stdin: String

    Returns void

  • Write on the input stream (stdin) of the external process.

    // Create some data to gzip
    var input = new Buffer( 'abcde', 'ascii' );
    // Create an asynchronous system worker
    var worker = new SystemWorker( 'gzip' );
    // Send the compressed file on stdin.
    worker.postMessage( input );
    // Note that we call endOfInput() to indicate we're done. gzip (and most program waiting data from stdin) will wait for more data until the input is explicitely closed.
    worker.endOfInput();

    Parameters

    Returns void

setBinary

  • setBinary(binary: Boolean): void
  • Set the type of data exchanged in the SystemWorker through the onmessage and onerror properties.

    workerProxy.setBinary(true);

    Parameters

    • binary: Boolean

      true to return binary data by onmessage and onerror, false otherwise.

    Returns void

terminate

  • terminate(waitForTermination?: Boolean, killProcessTree?: Boolean): void
  • Forces the system worker to terminate its execution.

    workerProxy.terminate();
    workerProxy.terminate(true, true);

    Parameters

    • Optional waitForTermination: Boolean

      (default: false) true if the current thread must wait for the system worker execution to end

    • Optional killProcessTree: Boolean

      (default: false) true if the system worker and all his childs must end

    Returns void

wait

  • wait(timeout?: Number): Boolean
  • Wait for the end of the system worker execution.

    workerProxy.wait(1000);
    workerProxy.wait();

    Parameters

    • Optional timeout: Number

      Millisecond to wait for.

    Returns Boolean