기본 콘텐츠로 건너뛰기

라벨이 coroutine인 게시물 표시

Fiber, future, 그리고 co-routine

맞춤법 검사를 위해 서버사이드에서 http.get 을 할 일이 있는데 meteor 에서 지원하는 future(node-fiber 라이브러리에 포함) 를 사용했다. 이거 블록으로 되어서 동시접속시에 망하는 거 아니냐라는 의혹을 불식시키기 위해 간단하게 코드를 짜보았다. meteor create future cd future vi future.js 하고 아래와 같이 부다다. if (Meteor.isClient) {   Template.hello.greeting = function () {     return "Welcome to future.";   };   Template.hello.events({     'click input' : function () {       // template data, if any, is available in 'this'       if (typeof console !== 'undefined')         console.log("You pressed the button");     }   }); } if (Meteor.isServer) {   Future = Npm.require('fibers/future');   Meteor.startup(function () {     // code to run on server at startup     Meteor.methods({       'future':function() {         console.log('future start:'+Date.now());         var fut...