在流星长计算 [英] Long computations on Meteor

查看:113
本文介绍了在流星长计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,在你的Node.js 长计算,以prevent阻塞服务器之间的收益率。你如何流星实现这一目标?是否有也在做这个客户端?

I learned that in Node.js you yield in between long computations to prevent the server from blocking. How do you achieve this on Meteor? Are there techniques for also doing this on the client?

我是新的网络开发,简单的例子是AP preciated。

I am new to web development, simple examples would be appreciated.

推荐答案

流星使用它们的行为比通常的Node.js code稍微不同的纤维。我认为没有必要手动屈服。相反,你可能需要使用 this.ublock()方法在服务器端 - 看的此内容真棒文章,解释它的细节。

Meteor uses Fibers which behave a little different than usual Node.js code. I believe there's no need to yield manually. Instead, you may want to use this.ublock() method on the server side – see this awesome article that explains it in details.

如果你正在做的事情在客户端真的很重(如计算Mandelbrot集),拆与推迟执行:

If you're doing something really heavy on the client side (like calculating Mandelbrot set), split the execution with defers:

_.defer(function() {
  doSomethingQuiteLong();
  _.defer(function() {
    doSomethingQuiteLongAgain();
    ...
  });
});

这篇关于在流星长计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆