2 Star 0 Fork 0

mirrors_Qihoo360 / pink

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

Pink

Build Status

Pink is a wrapper of pthread. Why you need it?

When you use pthread, you always define many type of thread, such as:

In network programming scenario, some thread used for accept the client's connection, some thread used for pass message to other thread, some thread used for communicate with client using protobuf.

So pink wrap a thin capsulation upon pthread to offer more convinent function.

Model

DispatchThread + Multi WorkerThread

Now pink support these type of thread:

DispatchThread:

DispatchThread is used for listen a port, and get an accept connection. And then dispatch this connection to the worker thread, you can use different protocol, now we have support google protobuf protocol. And you just need write the protocol, and then generate the code. The worker threads will deal with the protocol analysis, so it simplify your job.

Basic usage example:

PikaConnFactory conn_factory;
PikaServerHandle server_handle;
ServerThread *t = new NewDispatchThread(9211, /* server port */
                                        4,    /* worker's number */
                                        &conn_factory,
                                        1000,  /* cron interval */
                                        1000,  /* queue limit */
                                        &server_handle);
t->StartThread();

You can see example/mydispatch_srv.cc for more detail

HolyThread:

HolyThread just like the redis's main thread, it is the thread that both listen a port and do the job. When should you use HolyThread and When should you use DispatchThread combine with WorkerThread, if your job is not so busy, so you can use HolyThread do the all job. if your job is deal lots of client's request, we suggest you use DispathThread with worker threads.

Basic usage example:

PikaConnFactory conn_factory;
PikaServerHandle server_handle;
ServerThread *t = new NewHolyThread(9211, /* server port */
                                    &conn_factory,
                                    1000,  /* cron interval */
                                    &server_handle);
t->StartThread();

You can see example/myholy_srv_chandle.cc example/myholy_srv.cc for more detail

Now we will use pink build our project pika, floyd, zeppelin

In the future, I will add some thread manager in pink.

Dependencies

Performance

Test machines:

  --------         --------------
 |        |  <--- | Clients x200 |
 | Server |        --------------
 |        |        --------------
  --------   <--- | Clients x200 |
                   --------------

CPU, Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz, 24 cores

Memory, 142 GB

test program

Copyright (c) 2015-2020, Qihoo360 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

暂无描述 展开 收起
C++ 等 3 种语言
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors_Qihoo360/pink.git
git@gitee.com:mirrors_Qihoo360/pink.git
mirrors_Qihoo360
pink
pink
master

搜索帮助