As an analogy, pretend we had this code:
var safe = false;
var functionThatMustBeCalledSafely = function () {
if (!safe)
throw Error("It's not safe!");
...
};
Meteor.setTimeout = function (f, time) {
setTimeout(function () {
safe = true;
try {
f();
} finally {
safe = false;
}
}, time);
});
If you call setTimeout(functionThatMustBeCalledSafely, 100), then
functionThatMustBeCalledSafely will throw an error... because we
*DON'T* override setTimeout. Using Meteor.setTimeout, things work
properly.
In the actual case, "being called safely" means "being called in the
context of a Fiber", and functionThatMustBeCalledSafely is any
function that needs to block (yield) on IO, such as reading from a
database.
> --
> You received this message because you are subscribed to the Google Groups
> "meteor-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
meteor-talk...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.