Future
resizeFunctionWorkers(int count, WorkerFunction function, { Map<String, dynamic> metadata })
Source
resizeFunctionWorkers(int count, WorkerFunction function,
{Map<String, dynamic> metadata}) async {
if (sockets.length < count) {
for (var i = sockets.length + 1; i <= count; i++) {
var sock = createWorker(function, metadata: {
"workerId": i
}..addAll(metadata == null ? {} : metadata));
sock._pool = this;
sock.onReceivedMessageHandler = (msg) {
if (onMessageReceivedHandler != null) {
onMessageReceivedHandler(i, msg);
}
};
await sock.init();
sockets.add(sock);
}
} else {
await reduceWorkers(count);
}
}