All files / src index.ts

100% Statements 18/18
100% Branches 0/0
100% Functions 6/6
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5112x 12x 12x 12x           12x                 224x           12x 12x     12x 12x 12x             17x       13x 42x 12x 12x 13x 12x        
import { ConcurrencyException } from "@jonloucks/concurrency-ts/api/ConcurrencyException";
import { create as createConcurrencyFactory } from "./impl/ConcurrencyFactory.impl";
import { VERSION } from "./version";
import { Concurrency, ConcurrencyConfig, CONTRACT as CONCURRENCY_CONTRACT } from "@jonloucks/concurrency-ts/api/Concurrency";
import { ConcurrencyFactory } from "@jonloucks/concurrency-ts/api/ConcurrencyFactory";
 
/**
 * A shared global ConcurrencyFactory instance.
 */
const CONCURRENCY_FACTORY: ConcurrencyFactory = createConcurrencyFactory({});
 
/** 
 * Create a new Concurrency instance
 * @param config the Concurrency Config
 *
 * @return the new Concurrency instance
 */
function createConcurrency(config?: ConcurrencyConfig): Concurrency {
  return CONCURRENCY_FACTORY.createConcurrency(config);
}
 
/**
 * A shared global Concurrency instance.
 */
const CONCURRENCY : Concurrency = (() : Concurrency => { 
    const globalConfig : ConcurrencyConfig = { 
      shutdownEvents: ['exit']
    };
    const concurrency = createConcurrency(globalConfig);
    concurrency.open(); // closed on exit
    return concurrency;
})();
 
/**
 * concurrency-ts main index exports
 */
export {
  VERSION,
  Concurrency,
  ConcurrencyConfig,
  ConcurrencyFactory,
  ConcurrencyException,
  createConcurrencyFactory,
  createConcurrency,
  CONCURRENCY,
  CONCURRENCY_CONTRACT,
  CONCURRENCY_FACTORY
};