????C????Э??????????????
???????????? ???????[ 2013/1/21 10:22:46 ] ????????
????Э??
????Э?????Э??????????????????л?????????Э??????????CPU???????????Э?????????????Э?????????????Э???????????????????????????У???????????????????????????С? Э????????????????????????????????????python??lua??ruby???????????????????????????????????????golang rust-lang???????????????????λ?? Э??????????????????????????????????????2??????????
?????????????Э????????????ó?CPU?????????????????????Э?????У??????????κ?????п????????????????Э?????????????????????????????2???????????
?????????????Э????л??????????????????????????????????л????????С??
?????????????
???????????????????Щ?????????????????????????????????????????????????
???????????
?????????????????IO??????????IO???μ???read??IO?????????????????IO????????
???????????????????thread per connection?????????????????????accept???÷????????????μ????????????μ?socket???/д??????????????????????д?????????????????????????????????????????????????????????????????л????????????????
??????????
??????????????÷?????IO?????????epoll/select/poll???·??????????????????μ???read????????????????????????????????п????EAGAIN/EWOULDBLOCK????????????????????????????????????????????IO????
??????????????????reactor??????reactor????У????????????????IO??????????????IO??·???????У?????epoll/select/poll??????????????????·??????????????IO?????????????????·??????????????????IO????????????????????????????????У???????????read/write??????????IO??????
????????????????????????????????????ú?????????????????????д???????????????У?IO???????IO????????????IO??????????????????????????????
????Э??????????
????Э??????????????????????????????????????????? ?????????????3??Э??A??B??C????????????IO????????3??Э??????????????????????????????????У??????????CPU?????????????????????????·????????epoll/select/poll????
????Э??A???????У???????е????IO??????????IO??????????????????A????IO?????????????У???????????CPU?????????????B?л???CPU??????У?????????????????IO?????????IO?????????????У???????????CPU??????????C?л???cpu??????С???????Э?????“????”???????????????IO????????????????????Э??B????IO?????????????????????B????У?B??????η???CPU???????????????С?A??C????
??????????????????Э???????????????????????????????ó???????????????????
??????????????????????????????????????echo server??
????echo server
??????????????У?????????orchid??????д???echo server??orchid?????????????boost??????? Э??/????IO ??
????echo server???????????????????????????????Э???????????????????
typedef boost::shared_ptr socket_ptr;
//????ACCEPT?????Э?? void handle_accept(orchid::coroutine_handle co) {
try {
orchid::acceptor acceptor(co -> get_scheduler().get_io_service());//???????acceptor
acceptor.bind_and_listen("5678"??true);
for(;;) {
socket_ptr sock(new orchid::socket(co -> get_scheduler().get_io_service()));
acceptor.accept(*sock??co);
//???????????????Э?????????μ?socket????????????????????Э???main????????????????????????Э???????С??
co -> get_scheduler().spawn(boost::bind(handle_io??_1??sock)??orchid::minimum_stack_size());
}
} catch(boost::system::system_error& e) {
cerr<
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11