/*
Create a new pool of workers which run script file_name.

@param {Number} pool_size Pool size.
@param {String} file_name Name of the script which workers will run.
16972
function WorkerPool(pool_size, file_name) {
  events.EventEmitter.call(this);

  this._pool_size = pool_size;
  this._file_name = file_name;

  this._workers = []; // All the available workers
  this._active_workers = []; // Active workers
  this._idle_workers = []; // Idle workers
  this._pending_removal_workers = []; // Workers which are pending to be removed

  this._pending_jobs = [];
  this._is_terminated = false;
  this._pending_jobs_timeout_id = null;

  this._initialize();
}
210039
def pool_create(self, name, description, category):
        
        params = {
            'pool[name]': name,
            'pool[description]': description,
            'pool[category]': category
            }
        return self._get('pools.json', params, method='POST', auth=True)
1354331
function create() {
  var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
  var job  = jobs.create( 'video conversion', {
    title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
  } );

  job.on( 'complete', function () {
    console.log( " Job complete" );
  } ).on( 'failed', function () {
    console.log( " Job failed" );
  } ).on( 'progress', function ( progress ) {
    process.stdout.write( '\r  job #' + job.id + ' ' + progress + '% complete' );
  } );

  job.save();

  setTimeout( create, Math.random() * 2000 | 0 );
}
1081784
def new_file(new_name=false, body)
      f_name = new_name || file_name_with_path
      File.open(f_name, "w") { |line|
        line.write(body)
        line
      }
    end
817596
def initialize(name='', pool_size=10, host='localhost', password='', port=5432, user=''):
    

    global pool
    instance = Pool(name=name, pool_size=pool_size, host=host, password=password, port=port, user=user)
    pool = instance
    return instance
340955
static public CacheEntryPool createCacheEntryPool(DCache cache, int size) {
        CacheEntryPool pool = new CacheEntryPool(size, cache);
        return pool;
    }
1218479
function(name, data, enc, cbfscreatefile) {
        jsDAV_FS_Directory.createFile.call(this, name, data, enc,
            afterCreateFile.bind(this, name, cbfscreatefile));
    }
984285
function startWorkerPoolServer(options, listenCallback)
{
	var workerPool = createWorkerPool();
	var server = createServer(options);
	var logConnection = getOption(options, 'logConnection', true);
	var port = getOption(options, 'port', 0);

	server.on('client', (client) => {
		
		client.on('RGST', (msg) => {
			workerPool.addClient(client);
		});
		
		client.on('error', (e) => {
			workerPool.deleteClient(client);
		});
		
		client.on('close', () => {
			workerPool.deleteClient(client);
		});
	});
	
	server.listen({port: port}, () => {
		if ( logConnection )
		{
			console.log('LISTEN ' + port);
		}
		if ( listenCallback )
		{
			listenCallback(server);
		}
	});
	
	return workerPool;
}
1049742
function createAndFlush(size) {
            if (self._stream) {
                self._stream.end();
                self._stream.destroySoon();
            }

            self._size = size;
            self.filename = target;
            self._stream = fs.createWriteStream(fullname, self.options);

            //
            // We need to listen for drain events when
            // write() returns false. This can make node
            // mad at times.
            //
            self._stream.setMaxListeners(Infinity);

            //
            // When the current stream has finished flushing
            // then we can be sure we have finished opening
            // and thus can emit the `open` event.
            //
            self.once('flush', function () {
                // Because "flush" event is based on native stream "drain" event,
                // logs could be written inbetween "self.flush()" and here
                // Therefore, we need to flush again to make sure everything is flushed
                self.flush();

                self.opening = false;
                self.emit('open', fullname);
            });

            //
            // Remark: It is possible that in the time it has taken to find the
            // next logfile to be written more data than `maxsize` has been buffered,
            // but for sensible limits (10s - 100s of MB) this seems unlikely in less
            // than one second.
            //
            self.flush();
        }
1196927
function InitDB(db_name) {

    var sequelize = new Sequelize(db_name, config.db.username, config.db.password, {
        host: config.db.host
        ,dialect: config.db.type
        ,logging: config.db.logging ? function(msg) {
            fs.appendFileSync("db.log", msg.replace("Executing (default): ", "") + "\n\n");
            //logger.debug(msg);
        } : false
        ,pool: {
            idle: 20000
        }
        ,define: {
            createdAt: 'created_at'
            ,updatedAt: 'updated_at'
        }
    });

    var db = {};
    fs.readdirSync("./src/db").forEach(function(file) {
        var model = sequelize.import("../src/db/" + file);
        db[model.name] = model;
    });

    Object.keys(db).reduce(function(acc, modelName) {
        var model = db[modelName];
        if("associate" in model) {
            return acc.concat([model]);
        }
        return acc;
    }, []).forEach(function(model) {
        model.associate.apply(model, [db]);
    });

    return [sequelize, db];
}
96214
async def CreatePool(self, attrs, name, provider):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Storage',
                   request='CreatePool',
                   version=3,
                   params=_params)
        _params['attrs'] = attrs
        _params['name'] = name
        _params['provider'] = provider
        reply = await self.rpc(msg)
        return reply
309145
private void createPool(String poolName, Properties connectionPoolProperties) {

    releaseConnectionPool(poolName);

    // DBUtils execute methods require autoCommit to be true.
    connectionPoolProperties.put("autoCommit", true);

    HikariConfig config = new HikariConfig(connectionPoolProperties);
    config.setPoolName(poolName);
    HikariDataSource ds = new HikariDataSource(config);
    pools.put(poolName, ds);
    logger.info("Initialized pool '{}'", poolName);
  }
702373
def create_container
      name = @view.titleize.gsub(/ /, '')
      file = "client/containers/#{name}.js"
      copy_file "boilerplate/views/ContainerTemplate.js", file
      gsub_file file, /Placeholder/, name
    end
651856
async function buildSrcCheckMinifiedSizeTask() {
	const stats = await fs.stat( './dist/Autolinker.min.js' );
	const sizeInKb = stats.size / 1000;
	const maxExpectedSizeInKb = 46;
	
	if( sizeInKb > maxExpectedSizeInKb ) {
		throw new Error( `
			Minified file size of ${sizeInKb.toFixed( 2 )}kb is greater than max 
			expected minified size of ${maxExpectedSizeInKb}kb
			
			This check is to make sure that a dependency is not accidentally 
			added which significantly inflates the size of Autolinker. If 
			additions to the codebase have been made though and a higher size 
			is expected, bump the 'maxExpectedSizeInKb' number in gulpfile.js
		`.trim().replace( /^\t*/gm, '' ) );
	}
}
685922
function(size, name) {
    var fs = require('fs');
    var path = require('path');
    name = this.uniqueName(name);
    // Cannot set this as a world property because the world
    // is cleaned up before the AfterFeatures hook is fired.
    var fixturePath = path.resolve('./features/extra/fixtures/tmp');
    if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath);
    var filename = path.join(fixturePath, name);
    var body;
    if (typeof size === 'string') {
      switch (size) {
        case 'empty': body = new Buffer(0); break;
        case 'small': body = new Buffer(1024 * 1024); break;
        case 'large': body = new Buffer(1024 * 1024 * 20); break;
      }
    } else if (typeof size === 'number') {
      body = new Buffer(size);
    }

    fs.writeFileSync(filename, body);
    return filename;
  }
952802
function Queue(name, opts) {

	// allow call as function
	if (!(this instanceof Queue))
		return new Queue(name, opts);

	if (!name) {
		throw new Error('queue name is required');
	}

	opts = opts || {};

	// basic
	this.name = name;
	this.port = opts.port || 6379;
	this.host = opts.host || '127.0.0.1';

	// queue config
	this.config = {
		blockTimeout: opts.blockTimeout || 60
		, maxRetry: opts.maxRetry || 3
	};

	// redis options
	this.opts = opts;

	// main redis client
	this.client = Redis.createClient(this.port, this.host, this.opts);

	// client for blocking command only
	this.bclient = Redis.createClient(this.port, this.host, this.opts);

	// queue name
	this.prefix = 'dq:' + this.name;
	this.workQueue = this.prefix + ':work';
	this.runQueue = this.prefix + ':run';
	this.failQueue = this.prefix + ':fail';

	// status code
	this.status_timeout = 1;

	// queue status
	this.shutdown = false;
	this.running = false;

}
897081
static public EntryInfoPool createEntryInfoPool(String poolName, int size){
       final String methodName = "createEntryInfoPool()";
       EntryInfoPool pool = new EntryInfoPool(poolName, size);
       //pools.add(pool);
       if (tc.isDebugEnabled())
          Tr.debug(tc, methodName+" poolName=" + poolName);
       return pool;
   }