Giter Site home page Giter Site logo

pikalabs / pink Goto Github PK

View Code? Open in Web Editor NEW
316.0 58.0 160.0 4.9 MB

A high performance network library

Home Page: http://baotiao.github.io/

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.49% C++ 98.78% C 0.71% Shell 0.02%
thread framework network epoll-tcp-server

pink's Introduction

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

pink's People

Contributors

alexstocks avatar axlgrep avatar baotiao avatar catkang avatar flabby avatar git-hulk avatar jacketwoo avatar kernelai avatar kernelmaker avatar leviathan1995 avatar mindlesslcc avatar pingyym avatar prcyangli avatar songbingyu avatar wenduo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pink's Issues

Add pink benchmark

we have write an benchmark example in code.
However we havn't gave our test result, we need add the test result

improve or redesign bg_thread?

when I use bg_thread, sometime user was blocking in the function Schedule function, but pink tell the user nothing. And it's not easy to debug the problem.
So can we add some logs there, or the schedule function will return some flag to tell the caller.

版本发布计划

现在只有一个很久之前发布的release,有版本发布计划吗?

update pink readme

since pink has update to version 2, the Readme is too old.
we need update it

improve code style with cpplint.py

@gaodq

../include/pink_conn.h:5:  #ifndef header guard has wrong style, please use: PINK_INCLUDE_PINK_CONN_H_  [build/header_guard] [5]
../include/pink_conn.h:121:  #endif line should be "#endif  // PINK_INCLUDE_PINK_CONN_H_"  [build/header_guard] [5]
../include/pink_conn.h:27:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
../include/pink_conn.h:40:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
../include/pink_conn.h:42:  You don't need a ; after a }  [readability/braces] [4]
../include/pink_conn.h:41:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
../include/pink_conn.h:43:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
../include/pink_conn.h:44:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
../include/pink_conn.h:68:  You don't need a ; after a }  [readability/braces] [4]
../include/pink_conn.h:111:  You don't need a ; after a }  [readability/braces] [4]
../include/pink_conn.h:119:  Namespace should be terminated with "// namespace pink"  [readability/namespace] [5]

try to improve these code.

[Question] Relation with evpp

Hi, what's the connection with evpp? And do you think pink can have benefit by adopting libevent too? Thinking of a model like wangle or proxygen that specifically differentiates IO-related and CPU-related pools.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.