This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
process.nextTick(function() { | |
throw "hoge"; | |
}) | |
} catch(e) { | |
//ここには来ない・・・ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(fn) { | |
fn(); | |
} | |
try { | |
foo(function() { | |
throw "test"; | |
}); | |
} catch (e) { | |
//ここに到達します |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(fn) { | |
process.nextTick(fn); | |
} | |
try { | |
foo(function() { | |
throw "test"; | |
}); | |
} catch (e) { | |
//ここに到達しません・・・ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(fn) { | |
process.nextTick(fn); | |
} | |
var count = 0; | |
foo(function() { | |
try { | |
console.log(count++); | |
throw "test"; | |
} catch (e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210:ね、簡単でしょう? 魅力はこれだけではありません。ユーザがどのサーバーに接続しているかを気にする必要はありません。SocketStream サーバーは Redis の共通インスタンスを見ているのでメッセージは常に正しいサーバーへ送られます。◆→bekkou: こういうことを言いたいような気がするが、仕組みをちゃんと知らないので自信はない←◆ | |
242:◆→bekkou: 「内部/外部の関数呼び出しの確認は、開発モードでブラウザのコンソールから行えます」ってこと? incoming/outgoing のニュアンスが難しい←◆ | |
252:* メソッドに値◆→bekkou: incoming params ってなんぞ?←◆が渡されると、それらは最初の引数にまとめられます。最後の引数は常にコールバック関数(cb)です | |
266:* Stylusファイルは自動的にコンパイルされ、developmentモードの場合、そのまま送られます。staging もしくは production モードの場合、プリコンパイル、圧縮、キャッシュされます◆→bekkou: 仕組みを試してからもう一度見直したほうがいいかも←◆ | |
273:* ビューとテンプレートは自動的にコンパイルされ、developmentモードの場合、そのまま送られます。staging や production モードの場合、プリコンパイル、圧縮、キャッシュされます◆→bekkou: 仕組みを試してからもう一度見直したほうがいいかも←◆ | |
400:SocketStream は、全てのクライアントサイドのファイルと共有ファイルを「APIツリー」に対応づけるという新しいアプローチをとっています。APIツリーはグローバル変数 SS.client と SS.shared で参照できます。サーバサイドのコードは少し異なる動作をしますが、基本的には同じです(SS.server で参照します)。◆→bekkou: 参照の仕方は似ているが、動作は微妙に違うのかな?←◆ | |
456:ヘルパーはデフォルトでサーバサイドの SocketStream 全体で使われますが、クライアントサイド、共有コード、サーバコードでも同じように使えます。どこで実行できるかを気にする必要がありません。◆→bekkou: あれ。server-side と server code は同じ意味だと思っていたのだけど違うのかな。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serial(callbacks) | |
local i = 1 | |
local next | |
next = function() | |
i = i + 1 | |
local f = callbacks[i] | |
if f then | |
f(next) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parallel(callbacks, callback) | |
local next | |
local count = #callbacks | |
next = function() | |
count = count - 1 | |
if count == 0 then | |
callback() | |
end | |
end | |
for i, v in ipairs(callbacks) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chap18 | |
・デーモンプロセスはバックグランドで走るプロセス(ターミナルのコントロール下にはない) | |
・例えばWebサーバーとかDBとか | |
・デーモンプロセスはOSのコアでもある | |
・いろんなプロセスがシステムをうごかすためにバックグランドで走っている | |
・GUIシステム上のWIndowサーバーとかプリンタサービスとかオーディオサービスとか | |
・だから常に不快な'ding'音を鳴らすことができる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How Unicorn Reaps Worker Processes | |
RubyによるUnixプログラミングを掘り下げるなら、Unicorn web サーバーについても触れておく必要がある。既にこの本でも何度かUnicornについて言及をしてきた。 | |
Unicornの何が凄いのか?Unicornはkernelの機能を限界まで使いこなしている。 | |
コードベースはUnixプログラミングテクニックで一杯だ。 | |
それだけではなく、効率的で信頼性も備えている。GithubやShopifyといったRubyで構築されているWebサイトの多くがUnicornを使っている。 | |
RubyによるUnixプログラミングについてもっと興味がわいならUnicornの詳細を調べてみるといい。 |