2010-10-01から1ヶ月間の記事一覧

メモ:シグナル

シグナルを処理するだけの簡単なサンプルをc/node.js/pythonで。 #include <unistd.h> #include <string.h> static void func(){ write(2,"SIGINT\n",7); } int main(void){ struct sigaction act; //struct sigaction act2; memset(&act,0,sizeof act ); act.sa_handler = func;</string.h></unistd.h>…

JythonとCPython

PythonにはJVMで動作するJythonとネイティブのCpythonが存在していて、 それぞれ異なるGCのメカニズムを採用している。CPythonは、基本的に参照カウント方式で循環参照が発生した場合に限り マーク&スイープらしい。Jythonはというと、JVMに乗っかっているの…

メモ:スマートポインタ

#include <iostream> #include <memory> #include <tr1/memory> #include <string> #include <tr1/tuple> using namespace std; using namespace std::tr1; class Item { private: string value_; public: Item( const char* v="???") : value_(v) { cout << "create Item(" << value_ << ")" << endl; } ~Item</tr1/tuple></string></tr1/memory></memory></iostream>…

メモ:node.jsの拡張

js #!/usr/local/bin/node require.paths.push("./build/default/"); var obj = require("hello"); console.log(obj); cpp #include <v8.h> using namespace v8; extern "C" { void init ( Handle<Object> target ){ HandleScope scope; target->Set( String::New("hello")</object></v8.h>…