• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            網絡服務器軟件開發/中間件開發,關注ACE/ICE/boost

            C++博客 首頁 新隨筆 聯系 聚合 管理
              152 Posts :: 3 Stories :: 172 Comments :: 0 Trackbacks

            #

            這幾天,陸續在網上見到了幾個高中的好同學,發現曾經很優秀的他們,現在對游戲竟然都上癮了,由于高中管理嚴格,所以沒有機會出去玩,到了大學,
            可謂是天時地利人和,控制不住自己,瘋玩。工作混得一塌糊涂,卻不忘游戲,可嘆!再過上10年,人和人就會是天壤之別,希望他們早點清醒自己的頭腦,別在沉浸在游戲中了,是該奮斗的時候了!

            posted @ 2009-01-11 18:14 true 閱讀(910) | 評論 (10)編輯 收藏

            以后要努力做到這一點,也是提高開發速度的良方!
            posted @ 2008-12-10 16:37 true 閱讀(360) | 評論 (1)編輯 收藏

            白天寫代碼效率比較低,晚上愿意寫代碼,看來就是熬夜的命
            posted @ 2008-12-08 15:29 true 閱讀(358) | 評論 (3)編輯 收藏

            LNK2001 的一個原因如下,小知識不經常寫容易忘記,昨天下午到現在一天時間沒了
            成員模板的定義超出了類的范圍。Visual C++ 的一個限制是,成員模板的定義必須完全位于封閉類內
            posted @ 2008-11-21 10:15 true 閱讀(361) | 評論 (0)編輯 收藏

            像下面的好用工具函數就無法使用:
            string format_string(const char *fmt, ...)
            {
             /* Guess we need no more than 512 bytes. */
             int n, size = 512;
             char *p;
             va_list ap;
             if ((p = (char*)malloc (size)) == NULL)
              return "";
             while (1)
             {
              /* Try to print in the allocated space. */
              va_start(ap, fmt);
              n = vsnprintf (p, size, fmt, ap);
              va_end(ap);
              /* If that worked, return the string. */
              if (n > -1 && n < size)
              {
               string str(p);
               if(p)
                free(p);
               return str;
              }
              /* Else try again with more space. */
              if (n > -1)    /* glibc 2.1 */
               size = n+1; /* precisely what is needed */
              else           /* glibc 2.0 */
               size *= 2;  /* twice the old size */
              if ((p = (char*)realloc (p, size)) == NULL)
              {
               if(p)
                free(p);
               return "";
              }
             }
            }  

            posted @ 2008-10-07 10:17 true 閱讀(2341) | 評論 (2)編輯 收藏

                  浮躁是比較可怕的,技術上處于平原期,沒有什么提高,以后的路在何方?感慨萬千
            posted @ 2008-09-25 12:57 true 閱讀(266) | 評論 (0)編輯 收藏

                 message queue亦即消息隊列,在linux 下有msgsnd,msgrcv系列,在windows下有msmq,關于他們的相似及區別,請查閱相關資料,本文主要是簡單介紹一下boost提供的解決方案,及其性能。
               boost提供的message queue發送接口有send,try_send,timed_send,接收接口有receive,try_receive,timed_receive,其它接口有get_max_msg,get_max_msg_size,get_num_msg,remove。學習難度不高。下面測試一下send的發送速度:
                測試代碼:

            #define BOOST_ALL_DYN_LINK
            #include <boost/interprocess/ipc/message_queue.hpp>
            #include <boost/format.hpp>
            #include <boost/progress.hpp>
            #include <iostream>
            #include <string>
            #include <vector>

            using namespace boost;
            using namespace boost::interprocess;

            #define MAX_MSG_COUNT 50000
            #define MAX_MSG_SIZE 1024

            int main ()
            {
            try{
              //Erase previous message queue
              message_queue::remove("message_queue");

              //Create a message_queue.
              message_queue mq
               (create_only               //only create
               ,"message_queue"           //name
               ,MAX_MSG_COUNT                       //max message number
               ,MAX_MSG_SIZE               //max message size
               );
              
              
              {
               progress_timer pt;//記錄時間,多方便!
              
               for(int i = 0; i < 5000; ++i)//可靈活調整i的大小
               {    
                std::string msg = str(format("hello world %d") % i);
                bool bRet = mq.send(msg.c_str(),msg.size(),0);  
               }
              }
              
            }

            catch(interprocess_exception &ex)
            {
              message_queue::remove("message_queue");
              std::cout << ex.what() << std::endl;
              return 1;
            }
            //message_queue::remove("message_queue");
            return 0;
            }

              我的測試結果如下:
            500    0.16s
            1000   0.41/0.50  -->表示測了2次,第一次0.41s,第二次0.50s,下同
            5000條 5.88s/6.16
            10000  22.81s/22.34
            20000  87.92/91.22

               最后簡單總結一下boost message queue:
              優點:速度還不錯,接口學習起來簡單,方便易用
              缺點:我在windows下測試,當一直在寫隊列時,用ctrl + c中斷,然后用另一進程讀讀隊列,讀操作時阻塞。單步跟蹤發現
              是阻塞在interprocess_mutex::lock加鎖的操作上,健壯程度遠不如msgsnd,msgrcv系列,及msmq,該缺點比較致命。目前沒有測試linux下的情況。
            posted @ 2008-07-31 08:58 true 閱讀(7111) | 評論 (0)編輯 收藏

                 摘要: ADSL大型技術專題(圖文) 2007-5-23 8:24:59 隨著ADSL的普及,寬帶包月費用不斷的下調,現在越來越多的家庭用戶裝上了ADSL寬帶上網,申請了ADSL上網以后,該如何接入上網呢?需要什么設備?如果家里有多臺電腦,又該如何接入,使得A...  閱讀全文
            posted @ 2008-07-30 11:27 true 閱讀(6915) | 評論 (0)編輯 收藏

                 摘要:         關于echo的簡單server,幾乎多得發指,但大部分都沒有提供類似粘包,定時器,安全退出等開發中的常用機制,換句話說,為了echo而echo,借鑒價值大打折扣,畢竟我們平時的工作不可能這么簡單。這幾天研究了下asio,感覺不錯,boost接納asio后,在服務器開發領域是不是該得到重視呢:),還是貼代碼吧,有注...  閱讀全文
            posted @ 2008-07-20 13:45 true 閱讀(3686) | 評論 (3)編輯 收藏

            #include <iostream>
            #include <boost/asio.hpp>
            #include <boost/date_time/posix_time/posix_time.hpp>

            int main()
            {
             boost::asio::io_service io;

             boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
             t.wait();

             std::cout << "Hello, world!\n";

             return 0;
            }

            上面是boost文檔自帶的代碼,編譯出現錯誤。代碼是不需要鏈接libboost_system-vc80-mt-gd-1_35.lib,為什么還出現這樣的錯誤呢?他默認連接?知道的,恢復一下:)
            posted @ 2008-07-16 13:19 true 閱讀(11435) | 評論 (13)編輯 收藏

            僅列出標題
            共15頁: First 3 4 5 6 7 8 9 10 11 Last 
            中文成人无码精品久久久不卡| 狠狠狠色丁香婷婷综合久久俺| 久久精品国产精品亚洲下载| 久久精品综合网| 99国产精品久久久久久久成人热| 久久免费线看线看| 国产成人久久精品一区二区三区 | A级毛片无码久久精品免费| 久久er99热精品一区二区| 国产成人综合久久久久久| 思思久久精品在热线热| 高清免费久久午夜精品| 日本国产精品久久| 色综合久久综合网观看| 国内精品久久久久久99蜜桃| 无码人妻久久一区二区三区蜜桃| jizzjizz国产精品久久| 亚洲国产精品一区二区三区久久| 久久99精品国产99久久| 久久无码人妻一区二区三区午夜| 欧美久久一级内射wwwwww.| 久久久国产精品福利免费 | 人人狠狠综合久久亚洲高清| 国产亚洲欧美精品久久久| 久久亚洲日韩看片无码| 久久激情五月丁香伊人| 久久这里只有精品久久| 国内精品久久久久久99| 久久久国产精品亚洲一区| 香蕉aa三级久久毛片| 久久久久这里只有精品| 久久99久久无码毛片一区二区| 久久99热国产这有精品| 97久久国产亚洲精品超碰热| 日韩久久久久久中文人妻 | 国産精品久久久久久久| 亚洲成色999久久网站| 久久99精品国产一区二区三区| 国产精品视频久久| 91精品国产91热久久久久福利| 国产巨作麻豆欧美亚洲综合久久 |