OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #library('cluster'); |
| 6 #import('node.dart'); |
| 7 |
| 8 // module cluster |
| 9 |
| 10 /** |
| 11 * Note: cluster.fork will fail when run from frogsh. It will succeed |
| 12 * when dart code is compiled to JavaScript, and the resulting |
| 13 * JavaScript is run from node.js. |
| 14 */ |
| 15 |
| 16 typedef void ClusterDeathListener(ChildProcess cp); |
| 17 |
| 18 class cluster native "require('cluster')" { |
| 19 static void fork() native; |
| 20 static bool isMaster; |
| 21 static bool isWorker; |
| 22 |
| 23 // EventEmitter |
| 24 static void removeAllListeners(String event) native; |
| 25 static void setMaxListeners(num n) native; |
| 26 var _listeners(String key) |
| 27 native "return this.listeners(key);"; |
| 28 |
| 29 // Death event |
| 30 static void emitDeath(ChildProcess cp) |
| 31 native "this.emit('death', cp);"; |
| 32 static void addListenerDeath(ClusterDeathListener listener) |
| 33 native "this.addListener('death', listener);"; |
| 34 static void onDeath(ClusterDeathListener listener) |
| 35 native "this.on('death', listener);"; |
| 36 static void onceDeath(ClusterDeathListener listener) |
| 37 native "this.once('death', listener);"; |
| 38 static void removeListenerDeath(ClusterDeathListener listener) |
| 39 native "this.removeListener('death', listener);"; |
| 40 static List<ClusterDeathListener> listenersDeath() |
| 41 => new _NativeListPrimitiveElement<ClusterDeathListener>(_listeners( |
| 42 'death')); |
| 43 } |
OLD | NEW |