Home Reference Source Repository
import Fabric from 'wyst/es6/Queue/Fabric.js'
public class | source

Fabric

Extends:

eventemitter2~EventEmitterExpressive → Fabric

exposes a way to manage our underlying Threads

Constructor Summary

Public Constructor
public

Creates a new Fabric with the number of Threads equal to require('os').cpus().length * 2

Member Summary

Public Members
public get

availableThreads: Array<Process>: *

returns all Threads that are not currently working

public get

returns an Object that allows us to fetch <Process> by pids

public get

randomAvailableThread: Process: *

returns the Process reference to a random available thread

public get

threads: Array<Process>: *

getter for all of our underlying thread <Process>

Method Summary

Public Methods
public

invalidate(script: <type>)

invalidates a script across all running Threads

public

Kills all threads in a Fabric

public

reserve(thread: *): *

public

schedule(job: Object): *

Sends a job to a random available Thread for processing

Inherited Summary

From class Expressive
public static

create(): *

creates a new inherited instance

public

debug: *

public

is(state: string): *

expressive emit

public

when(): *

expressive once

Public Constructors

public constructor source

Creates a new Fabric with the number of Threads equal to require('os').cpus().length * 2

Override:

Expressive#constructor

Public Members

public get availableThreads: Array<Process>: * source

returns all Threads that are not currently working

Return:

Array<Process>

public get byPid: Object: * source

returns an Object that allows us to fetch <Process> by pids

Return:

Object

key, value pairs of pid, <Process> respectively

public get randomAvailableThread: Process: * source

returns the Process reference to a random available thread

Return:

Process

public get threads: Array<Process>: * source

getter for all of our underlying thread <Process>

Return:

Array<Process>

Public Methods

public invalidate(script: <type>) source

invalidates a script across all running Threads

Params:

NameTypeAttributeDescription
script <type>

The script

public kill(): Promise source

Kills all threads in a Fabric

Return:

Promise

public reserve(thread: *): * source

Params:

NameTypeAttributeDescription
thread *

Return:

*

public schedule(job: Object): * source

Sends a job to a random available Thread for processing

Params:

NameTypeAttributeDescription
job Object

The job

Return:

*