当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ChildProcess.send方法代码示例

本文整理汇总了TypeScript中child_process.ChildProcess.send方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ChildProcess.send方法的具体用法?TypeScript ChildProcess.send怎么用?TypeScript ChildProcess.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在child_process.ChildProcess的用法示例。


在下文中一共展示了ChildProcess.send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

				send: r => this.child && this.child.connected && this.child.send(r),
开发者ID:DoubleCatGames,项目名称:vscode,代码行数:1,代码来源:ipc.cp.ts

示例2: fork

        completedCreation.then(() => {
            console.timeEnd('Create DB');

            // create the threads that will access the database
            let threads:Array<ChildProcess> = new Array<ChildProcess>();
            console.log("Creating Threads");
            for (let i = 0; i < threadCount; ++i) {
                let new_child:ChildProcess;
                if (mode == DBMode.RacerTable) {
                    new_child = fork('./stress-test-racer');
                } else if (mode == DBMode.TeamTable) {
                    new_child = fork('./stress-test-team');
                }
                new_child.send({
                    type:             'generate',
                    teams:            teams,
                    racersATeam:      racersATeam,
                    updateQueryRatio: updateQueryRatio,
                    thisThreadNum:    i,
                    totalThreads:     threadCount,
                    accessCount:      accessCount
                });
                threads.push(new_child);
            }
            // run the three tests once after another
            async.series([
                (callback:(err:Error)=>void) => {
                    // Wait for all threads to be ready
                    Promise.all(threads.map(thread=>new Promise((resolve, reject)=> {
                        thread.once('message', (msg:string) => msg === 'ready' ? resolve() : reject())
                    }))).then(() => {
                        console.log('All Threads Ready');
                        callback(null);
                    }).catch(() => callback(new Error('Thread Error')));
                },
                (callback:(err:Error)=>void) => {
                    console.time("Update from all Threads");
                    Promise.all(threads.map(thread=>new Promise((resolve, reject)=> {
                        thread.send('update');
                        thread.once('message', (msg:string) => msg === 'update' ? resolve() : reject());
                    }))).then(() => {
                        console.timeEnd("Update from all Threads");
                        callback(null);
                    }).catch(() => callback(new Error('Thread Error')));
                },
                (callback:(err:Error)=>void) => {
                    console.time("Query from all Threads");
                    Promise.all(threads.map(thread=>new Promise((resolve, reject)=> {
                        thread.send('query');
                        thread.once('message', (msg:string) => msg === 'query' ? resolve() : reject());
                    }))).then(()=> {
                        console.timeEnd("Query from all Threads");
                        callback(null);
                    }).catch(() => callback(new Error('Thread Error')));
                },
                (callback:(err:Error)=>void) => {
                    console.time("Update and Query from all Threads");
                    Promise.all(threads.map(thread=>new Promise((resolve, reject)=> {
                        thread.send('both');
                        thread.once('message', (msg:string) => msg === 'both' ? resolve() : reject());
                    }))).then(()=> {
                        console.timeEnd("Update and Query from all Threads");
                        callback(null);
                    }).catch(() => callback(new Error('Thread Error')));
                },
                (callback:(err:Error)=>void) => {
                    threads.map((thread:ChildProcess)=>thread.disconnect());
                    db.close();
                    callback(null);
                }
            ]);
        });
开发者ID:Tiedye,项目名称:RazzieTest,代码行数:72,代码来源:index.ts

示例3:

			const send = r => this.child && this.child.connected && this.child.send(r);
开发者ID:aminroosta,项目名称:vscode,代码行数:1,代码来源:ipc.cp.ts


注:本文中的child_process.ChildProcess.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。