workers: rename.
This commit is contained in:
parent
a1ec1bfff1
commit
3014229d9a
@ -219,7 +219,7 @@ function Environment() {
|
||||
|
||||
// Workers
|
||||
this.require('workers', './workers');
|
||||
this.require('workerpool', './workers/workers'); // -> workerpool
|
||||
this.require('workerpool', './workers/workerpool');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,7 @@ var Input = require('../primitives/input');
|
||||
var Output = require('../primitives/output');
|
||||
var time = require('../net/timedata');
|
||||
var mine = require('./mine');
|
||||
var workers = require('../workers/workers');
|
||||
var workerPool = require('../workers/workerpool').pool;
|
||||
|
||||
/**
|
||||
* MinerBlock
|
||||
@ -346,7 +346,7 @@ MinerBlock.prototype.findNonceAsync = co(function* findNonceAsync() {
|
||||
|
||||
while (max <= 0xffffffff) {
|
||||
data = block.abbr();
|
||||
nonce = yield workers.pool.mine(data, target, min, max);
|
||||
nonce = yield workerPool.mine(data, target, min, max);
|
||||
|
||||
if (nonce !== -1)
|
||||
break;
|
||||
|
||||
@ -14,7 +14,7 @@ var assert = require('assert');
|
||||
var Network = require('../protocol/network');
|
||||
var Logger = require('./logger');
|
||||
var time = require('../net/timedata');
|
||||
var workers = require('../workers/workers');
|
||||
var workerPool = require('../workers/workerpool').pool;
|
||||
|
||||
/**
|
||||
* Base class from which every other
|
||||
@ -104,15 +104,15 @@ Node.prototype._onOpen = function _onOpen() {
|
||||
self.logger.warning('Please make sure your system clock is correct!');
|
||||
});
|
||||
|
||||
this._bind(workers.pool, 'spawn', function(child) {
|
||||
this._bind(workerPool, 'spawn', function(child) {
|
||||
self.logger.info('Spawning worker process: %d.', child.id);
|
||||
});
|
||||
|
||||
this._bind(workers.pool, 'exit', function(code, child) {
|
||||
this._bind(workerPool, 'exit', function(code, child) {
|
||||
self.logger.warning('Worker %d exited: %s.', child.id, code);
|
||||
});
|
||||
|
||||
this._bind(workers.pool, 'error', function(err, child) {
|
||||
this._bind(workerPool, 'error', function(err, child) {
|
||||
if (child) {
|
||||
self.logger.error('Worker %d error: %s', child.id, err.message);
|
||||
return;
|
||||
|
||||
@ -20,7 +20,7 @@ var Output = require('./output');
|
||||
var Coin = require('./coin');
|
||||
var KeyRing = require('./keyring');
|
||||
var Address = require('./address');
|
||||
var workers = require('../workers/workers');
|
||||
var workerPool = require('../workers/workerpool').pool;
|
||||
var encoding = require('../utils/encoding');
|
||||
|
||||
/**
|
||||
@ -399,7 +399,7 @@ MTX.prototype.scriptVector = function scriptVector(prev, vector, ring) {
|
||||
*/
|
||||
|
||||
MTX.prototype.signInputAsync = function signInputAsync(index, ring, type) {
|
||||
return workers.pool.signInput(this, index, ring, type);
|
||||
return workerPool.signInput(this, index, ring, type);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -905,7 +905,7 @@ MTX.prototype.sign = function sign(ring, type) {
|
||||
*/
|
||||
|
||||
MTX.prototype.signAsync = function signAsync(ring, type) {
|
||||
return workers.pool.sign(this, ring, type);
|
||||
return workerPool.sign(this, ring, type);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,7 @@ var Output = require('./output');
|
||||
var Outpoint = require('./outpoint');
|
||||
var Coin = require('./coin');
|
||||
var InvItem = require('./invitem');
|
||||
var workers = require('../workers/workers');
|
||||
var workerPool = require('../workers/workerpool').pool;
|
||||
var BufferWriter = require('../utils/writer');
|
||||
var BufferReader = require('../utils/reader');
|
||||
|
||||
@ -759,7 +759,7 @@ TX.prototype.verifyAsync = function verifyAsync(flags) {
|
||||
if (this.isCoinbase())
|
||||
return Promise.resolve(true);
|
||||
|
||||
return workers.pool.verify(this, flags);
|
||||
return workerPool.verify(this, flags);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -780,7 +780,7 @@ TX.prototype.verifyInputAsync = function verifyInputAsync(index, flags) {
|
||||
|
||||
assert(input, 'Input does not exist.');
|
||||
|
||||
return workers.pool.verifyInput(this, index, flags);
|
||||
return workerPool.verifyInput(this, index, flags);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
exports.encoding = require('./encoding');
|
||||
exports.Opcode = require('./opcode');
|
||||
exports.Program = require('./program');
|
||||
exports.Script = require('./script');
|
||||
|
||||
@ -3,4 +3,5 @@
|
||||
exports.jobs = require('./jobs');
|
||||
exports.Framer = require('./framer');
|
||||
exports.Parser = require('./parser');
|
||||
exports.WorkerPool = require('./workers');
|
||||
exports.Worker = require('./workerpool').Worker;
|
||||
exports.WorkerPool = require('./workerpool').WorkerPool;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* workers.js - worker processes for bcoin
|
||||
* workerpool.js - worker processes for bcoin
|
||||
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
|
||||
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
|
||||
* https://github.com/bcoin-org/bcoin
|
||||
@ -49,6 +49,18 @@ function WorkerPool(options) {
|
||||
|
||||
utils.inherits(WorkerPool, EventEmitter);
|
||||
|
||||
/**
|
||||
* Whether workers are supported.
|
||||
* @const {Boolean}
|
||||
*/
|
||||
|
||||
WorkerPool.support = true;
|
||||
|
||||
if (utils.isBrowser) {
|
||||
WorkerPool.support = typeof global.Worker === 'function'
|
||||
|| typeof global.postMessage === 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of CPUs/cores available.
|
||||
* @const {Number}
|
||||
@ -221,7 +233,7 @@ WorkerPool.prototype.destroy = function destroy() {
|
||||
WorkerPool.prototype.execute = function execute(method, args, timeout) {
|
||||
var result, child;
|
||||
|
||||
if (!this.enabled || !exports.support) {
|
||||
if (!this.enabled || !WorkerPool.support) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
utils.nextTick(function() {
|
||||
try {
|
||||
@ -677,13 +689,6 @@ function toError(values) {
|
||||
exports.pool = new WorkerPool();
|
||||
exports.pool.enabled = false;
|
||||
|
||||
exports.support = true;
|
||||
|
||||
if (utils.isBrowser) {
|
||||
exports.support = typeof global.Worker === 'function'
|
||||
|| typeof global.postMessage === 'function';
|
||||
}
|
||||
|
||||
exports.set = function set(options) {
|
||||
if (typeof options.useWorkers === 'boolean')
|
||||
this.pool.enabled = options.useWorkers;
|
||||
Loading…
Reference in New Issue
Block a user