Class: MonsterEngine::Server
- Inherits:
-
Object
- Object
- MonsterEngine::Server
- Defined in:
- ext/monster_engine/monster_engine_server.c
Instance Method Summary collapse
Constructor Details
#initialize(rb_plamo_app, rb_monster_engine_config) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'ext/monster_engine/monster_engine_server.c', line 31
static VALUE initialize(VALUE self, VALUE rb_plamo_app, VALUE rb_monster_engine_config) {
rb_iv_set(self, "@config", rb_monster_engine_config);
PlamoApp *plamo_app;
TypedData_Get_Struct(rb_plamo_app, PlamoApp, &rb_plamo_app_type, plamo_app);
MonsterEngineConfig *monster_engine_config;
TypedData_Get_Struct(rb_monster_engine_config, MonsterEngineConfig, &rb_monster_engine_config_type, monster_engine_config);
DATA_PTR(self) = monster_engine_server_new(plamo_app, monster_engine_config);
return self;
}
|
Instance Method Details
#start ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'ext/monster_engine/monster_engine_server.c', line 51
static VALUE start(VALUE self) {
VALUE rb_config = rb_iv_get(self, "@config");
const unsigned int workers = FIX2UINT(rb_iv_get(rb_config, "@workers"));
for (int i = 0; i < workers; i++) {
pid_t pid = fork();
if (pid == 0) {
rb_thread_create(plamo_rb_event_thread, NULL);
rb_thread_call_without_gvl(callback, DATA_PTR(self), RUBY_UBF_PROCESS, NULL);
break;
} else if (pid == -1) {
break;
}
}
while (true) {
sleep(1);
}
return Qnil;
}
|