{"id":13630114,"url":"https://github.com/PikaLabs/pink","last_synced_at":"2025-04-17T13:31:26.703Z","repository":{"id":31954002,"uuid":"35523883","full_name":"PikaLabs/pink","owner":"PikaLabs","description":"A high performance network library","archived":false,"fork":false,"pushed_at":"2023-02-09T20:15:29.000Z","size":5015,"stargazers_count":318,"open_issues_count":6,"forks_count":162,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-11-08T21:38:29.721Z","etag":null,"topics":["epoll-tcp-server","framework","network","thread"],"latest_commit_sha":null,"homepage":"http://baotiao.github.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PikaLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-05-13T02:31:23.000Z","updated_at":"2024-11-03T21:00:23.000Z","dependencies_parsed_at":"2023-01-14T20:12:09.834Z","dependency_job_id":"de48b9ae-3334-45e9-b672-d0d0b570df34","html_url":"https://github.com/PikaLabs/pink","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Fpink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Fpink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Fpink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Fpink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PikaLabs","download_url":"https://codeload.github.com/PikaLabs/pink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249344793,"owners_count":21254736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["epoll-tcp-server","framework","network","thread"],"created_at":"2024-08-01T22:01:30.618Z","updated_at":"2025-04-17T13:31:26.189Z","avatar_url":"https://github.com/PikaLabs.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"## Pink\n\n[![Build Status](https://travis-ci.org/PikaLabs/pink.svg?branch=master)](https://travis-ci.org/PikaLabs/pink)\n\nPink is a wrapper of pthread. Why you need it?\n\nWhen you use pthread, you always define many type of thread, such as:\n\nIn network programming scenario, some thread used for accept the client's connection, some thread used for pass\nmessage to other thread, some thread used for communicate with client using protobuf.\n\nSo pink wrap a thin capsulation upon pthread to offer more convinent function.\n\n### Model\n\nDispatchThread + Multi WorkerThread\n\n![](http://i.imgur.com/XXfibpV.png)\n\nNow pink support these type of thread:\n\n#### DispatchThread: \n\nDispatchThread is used for listen a port, and get an accept connection. And then\ndispatch this connection to the worker thread, you can use different protocol,\nnow we have support google protobuf protocol. And you just need write the\nprotocol, and then generate the code. The worker threads will deal with the\nprotocol analysis, so it simplify your job.\n\nBasic usage example:\n\n```\nPikaConnFactory conn_factory;\nPikaServerHandle server_handle;\nServerThread *t = new NewDispatchThread(9211, /* server port */\n                                        4,    /* worker's number */\n                                        \u0026conn_factory,\n                                        1000,  /* cron interval */\n                                        1000,  /* queue limit */\n                                        \u0026server_handle);\nt-\u003eStartThread();\n\n```\n\nYou can see example/mydispatch_srv.cc for more detail\n\n\n#### HolyThread:\n\nHolyThread just like the redis's main thread, it is the thread that both listen a port and do\nthe job. When should you use HolyThread and When should you use DispatchThread\ncombine with WorkerThread, if your job is not so busy, so you can use HolyThread\ndo the all job. if your job is deal lots of client's request, we suggest you use\nDispathThread with worker threads.\n\nBasic usage example:\n\n```\nPikaConnFactory conn_factory;\nPikaServerHandle server_handle;\nServerThread *t = new NewHolyThread(9211, /* server port */\n                                    \u0026conn_factory,\n                                    1000,  /* cron interval */\n                                    \u0026server_handle);\nt-\u003eStartThread();\n\n```\n\nYou can see example/myholy_srv_chandle.cc example/myholy_srv.cc for more detail\n\nNow we will use pink build our project [pika](https://github.com/Qihoo360/pika), [floyd](https://github.com/PikaLabs/floyd), [zeppelin](https://github.com/Qihoo360/zeppelin)\n\nIn the future, I will add some thread manager in pink.\n\n### Dependencies\n\n- [slash v1.0+](https://github.com/PikaLabs/slash)\n\n- [protobuf v2.5.0](https://github.com/google/protobuf/releases/tag/v2.5.0)\n\n- OpenSSL if enable ssl\n\n### Performance\n\nTest machines:\n\n```\n  --------         --------------\n |        |  \u003c--- | Clients x200 |\n | Server |        --------------\n |        |        --------------\n  --------   \u003c--- | Clients x200 |\n                   --------------\n```\n\nCPU, Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz, 24 cores\n\nMemory, 142 GB\n\n[test\nprogram](https://github.com/PikaLabs/pink/tree/master/pink/example/performance)\n\n![](https://ws4.sinaimg.cn/large/006tKfTcly1fho384upsjj30f00a5gm8.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPikaLabs%2Fpink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPikaLabs%2Fpink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPikaLabs%2Fpink/lists"}