構建高性能系統的C語言事件框架:libPhenom

jopen 11年前發布 | 29K 次閱讀 libPhenom C/C++開發

libPhenom 是 非死book 發布的一個C語言事件框架,用于構建高性能和高可擴展的系統。支持多線程,提供內存管理和常用數據結構(hash tables, lists, queues),json處理。

  • Memory management with counters - record how much of which kinds of memory your application is using.
  • Jobs - decompose your application into portions of work and let the phenom scheduler manage getting them done
  • streaming I/O with buffers
  • Handy data structures (hash tables, lists, queues)
  • Variant數據類型,實現JSON的序列化和反序列化
  • A printf implementation with registerable object formatting

示例代碼:

#include "phenom/defs.h"
#include "phenom/job.h"
#include "phenom/log.h"
#include "phenom/sysutil.h"

int main(int argc, char **argv)
{
  // Must be called prior to calling any other phenom functions
  ph_library_init();
  // Optional config file for tuning internals
  ph_config_load_config_file("/path/to/my/config.json");
  // Enable the non-blocking IO manager
  ph_nbio_init(0);

  // Do stuff here to register client/server stuff.
  // This enables a very simple request/response console
  // that allows you to run diagnostic commands:
  // `echo memory | nc -UC /tmp/phenom-debug-console`
  // The code behind this is in
  // https://github.com/非死book/libphenom/blob/master/corelib/debug_console.c
  ph_debug_console_start("/tmp/phenom-debug-console");

  // Run
  ph_sched_run();

  return 0;
}

項目主頁:http://www.baiduhome.net/lib/view/home/1379399879568

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!