您的位置:首页 > 编程语言 > C语言/C++

libPhenom:Facebook开源的高性能C语言并发编程框架

2017-03-01 22:22 260 查看
http://hao.jobbole.com/libphenom/


libPhenom:Facebook开源的高性能C语言并发编程框架

本资源由 伯乐在线 - 冰斌 整理,您也想贡献一份力量?欢迎加入我们
»



libPhenom是Facebook发布的一个C语言事件框架,用于构建高性能和高可扩展的系统。支持多线程、提供内存管理和常用数据结构、json处理。


特性

带有计数器的内存管理——记录应用程序正使用的内存类型的次数。
工作——分解你的应用程序并用调度管理来搞定它们
带缓冲的I/O流
常用的数据结构 (哈希表, 列表, 队列)
数据类型的变种来使能JSON的序列化和反序列化
带有注册对象格式的printf的实现


 目标

平衡易用性与性能
目的是对于你选择的螺纹或基于事件的调度保持中立并很好的完成它们
如果可能,避免我们实施过程中的争用点从而避免系统中芯扩展性的限制


如何使用文档

如果你阅读 http://facebook.github.io/libphenom,简单的开始输入,搜索框就会提示主题。你可以从主题菜单中选择主题或者通过头菜单浏览头文件。


获得源码

你可以从中 https://github.com/facebook/libphenom 获得源文件:

1$ git clone https://github.com/facebook/libphenom.git

创建


1

2

3

4

5

$
./autogen.sh

$
./configure

$
make

$
make
check

$
sudo
make
install


应用程序示例

Objective-C

123456789101112131415161718192021222324252627#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/facebook/libphenom/blob/master/corelib/debug_console.c  ph_debug_console_start("/tmp/phenom-debug-console");   // Run  ph_sched_run();   return 0;}
使用下面的命令编译该程序:

1

$
gcc
-O2
main.c
`pkg-config
libphenom
--cflags
--libs`

更多例子请参阅:https://github.com/facebook/libphenom/blob/master/examples/echo.c


官方网站:http://facebook.github.io/libphenom/index.html

开源地址:https://github.com/facebook/libphenom
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息