{"id":188234,"date":"2013-07-29T22:06:03","date_gmt":"2013-07-29T18:06:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=188234"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=188234","title":{"rendered":"<span class=\"post_title\">\u041f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 ThreadPool \u0441 async \u0438 future<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043e\u0431\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a! \u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 MMORPG. \u0412 \u0438\u0433\u0440\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 \u0434\u0432\u0438\u0436\u043e\u043a, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041d\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0432\u0430\u043d\u0438\u0435 XML \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0438 \u0442.\u0434. \u0418 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0438\u0433\u0440\u044b \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f fps.<br \/>  \u0412\u043e\u043e\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0433\u0443\u0433\u043b\u043e\u043c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043e \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 <s>\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 <\/s> ThreadPool. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0438 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0441 \u0432\u0430\u043c\u0438. <\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0418 \u0442\u0430\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u0430\u043c \u043f\u0443\u043b \u0438 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0443\u043b\u043e\u043c. <br \/>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b:<\/p>\n<pre><code class=\"cpp\">#include &lt;functional&gt; #include &lt;thread&gt; #include &lt;queue&gt; #include &lt;mutex&gt; #include &lt;memory&gt;  using std::function; using std::queue; using std::mutex; using std::thread; using std::shared_ptr; using std::vector; <\/code><\/pre>\n<h4>\u041a\u043b\u0430\u0441\u0441 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430:<\/h4>\n<pre><code class=\"cpp\">typedef function&lt;void()&gt; fn_type;  class Worker {     public:  \tWorker() \t\t:enabled(true),fqueue() \t\t,thread(&Worker::thread_fn, this) \t{} \t~Worker() \t{ \t\tenabled = false; \t\tthread.join(); \t}   \tvoid appendFn(fn_type fn) \t{ \t\tmutex.lock(); \t\tfqueue.push(fn); \t\tmutex.unlock(); \t}  \tqueue&lt;fn_type&gt;\tfqueue;  protected:  \tmutex\t\tmutex; \tthread\t\tthread; \tvolatile bool\tenabled;\t  \tvoid thread_fn(); };  typedef shared_ptr&lt;Worker&gt; worker_ptr; <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u044e\u0442\u0435\u043a\u0441 \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u0430\u043c <a href=\"http:\/\/en.cppreference.com\/w\/cpp\/thread\/thread\">std::thread<\/a>, \u0444\u043b\u0430\u0433 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432 std::function&lt;void()&gt;. \u0412\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u2013 \u0430 \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432? \u041e\u0442\u0432\u0435\u0442 \u0436\u0434\u0435\u0442 \u0432\u0430\u0441 \u043d\u0438\u0436\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. <br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">void Worker::thread_fn() { \twhile (enabled) \t{ \t\tif(!fqueue.empty()) \t\t{ \t\t\tmutex.lock(); \t\t\tfn_type fn = fqueue.front(); \t\t\tfqueue.pop(); \t\t\tmutex.unlock(); \t\t\tfn(); \t\t} \t\telse \t\t\tstd::this_thread::yield(); \/\/ \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u0443\u0442 sleep \t} } <\/code><\/pre>\n<p>  \u0412 \u0446\u0438\u043a\u043b\u0435 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432. \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u2014 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c. <br \/>  \u042d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<h4>\u041a\u043b\u0430\u0441\u0441 ThreadPool<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u042f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u043f\u043b\u044e\u0448\u043a\u0438 \u0442\u0438\u043f\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c\u0438, \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u0438 \u0442.\u043f. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c. <\/p>\n<pre><code class=\"cpp\">class ThreadPool { public:  \tThreadPool(size_t threads = 1) \t{ \t\tif (threads==0) \t\t\tthreads=1; \t\tfor (size_t i=0; i&lt;threads; i++) \t\t{ \t\t\tworker_ptr pWorker(new Worker); \t\t\t_workers.push_back(pWorker); \t\t} \t} \t~ThreadPool() \t{ \t\t_workers.clear(); \t}  protected: \t\t \tworker_ptr getFreeWorker();  \tvector&lt;worker_ptr&gt; _workers;   }; <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u043b. <br \/>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e getFreeWorker:<\/p>\n<pre><code class=\"cpp\">worker_ptr Worker::getFreeWorker() { \tworker_ptr pWorker = _workers[0]; \tsize_t minTasks = pWorker-&gt;fqueue.size();\t\t\t\t \tfor (auto &it : _workers) \t{ \t\tif (it-&gt;fqueue.empty()) \t\t\treturn it; \t\telse if (minTasks &gt; it-&gt;fqueue.size()) \t\t{ \t\t\tminTasks = it-&gt;fqueue.size(); \t\t\tpWorker = it; \t\t} \t} \treturn pWorker; } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043b\u0438\u0431\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e. <br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e. <\/p>\n<h4>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/h4>\n<p>  \u041e\u043a\u0435\u0439, \u043f\u0443\u043b \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e? <br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0421++11 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"http:\/\/en.cppreference.com\/w\/cpp\/utility\/functional\/bind\">std::bind<\/a>, \u043b\u044f\u043c\u0431\u0434\u044b, <a href=\"http:\/\/en.cppreference.com\/w\/cpp\/utility\/functional\/function\">std::function<\/a> \u0438 variadic templates.<br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043b\u0430\u0441\u0441 ThreadPool \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">template&lt;class _FN, class... _ARGS&gt; void runAsync(_FN _fn, _ARGS... _args) { \tgetFreeWorker()-&gt;appendFn(std::bind(_fn,_args...)); } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041c\u044b \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0435\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e bind&#8217;a \u0432 \u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">void foo()\t\t\t\t\t {  \tstd::cout &lt;&lt; &quot;foo()&quot; &lt;&lt; std::endl;  } void foo2(int i, float f)\t {  \tstd::cout &lt;&lt; &quot;foo2(&quot; &lt;&lt; i &lt;&lt; &quot;, &quot; &lt;&lt; f &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;  } struct Baz { \tvoid bar()  \t{  \t\tstd::cout &lt;&lt; &quot;Baz::bar()&quot; &lt;&lt; std::endl;  \t} \tvoid bar2(double d, const std::string &str)  \t{  \t\tstd::cout &lt;&lt; &quot;Baz::bar2(&quot; &lt;&lt; d &lt;&lt; &quot;, &quot; &lt;&lt; str &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;  \t} };  int main() { \tThreadPool pool;  \tBaz* pBaz = new Baz(); \tBaz baz;  \tstd::function&lt;void(int,int)&gt; myFn = [&](int a, int b) \t{  \t\tstd::cout &lt;&lt; &quot;functor(&quot; &lt;&lt; a &lt;&lt; &quot;, &quot; &lt;&lt; b &lt;&lt; &quot;)&quot; &lt;&lt; std::endl; \t };  \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \tpool.runAsync(&foo); \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \tpool.runAsync(&foo2,100,54.5f); \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c 2\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \tpool.runAsync(&Baz::bar,pBaz); \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 * \tpool.runAsync(&Baz::bar2,&baz,400.3,&quot;Hello World!&quot;); \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u043b\u044f\u043c\u0431\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \tpool.runAsync([](){ std::cout &lt;&lt; &quot;lambda()&quot; &lt;&lt; std::endl; }); \t\/\/ \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 \tpool.runAsync(myFn,10,20); } <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435, \u043b\u0438\u0431\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u043d\u043e\u0433\u043e:<\/p>\n<p>  foo()<br \/>  foo2(100, 54.5)<br \/>  Baz::bar()<br \/>  Baz::bar2(400.3, Hello World!)<br \/>  lambda()<br \/>  functor(10, 20)<\/p><\/div>\n<\/div>\n<p>  * \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0433\u0434\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 Baz \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u044d\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u043e \u0442\u0430\u043a \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d, \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0443\u043f\u0430\u0434\u0435\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 <a href=\"http:\/\/en.cppreference.com\/w\/cpp\/thread\/future\">std::future<\/a>.<\/p>\n<pre><code class=\"cpp\">template&lt;class _T&gt; struct AData { \tAData():ready(false){} \tvolatile bool ready; \t_T data; }; <\/code><\/pre>\n<p>  \u0414\u0432\u0430 \u043f\u043e\u043b\u044f, \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0436\u0435\u0442 \u043d\u0430\u043c \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e.<br \/>  \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u043e\u043d std::future, \u0441 wait \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0445\u0432\u0430\u0442\u0438\u0442 \u0438 \u044d\u0442\u043e\u0433\u043e. <\/p>\n<p>  \u0421\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">template&lt;class _R, class _FN, class... _ARGS&gt; shared_ptr&lt;AData&lt;_R&gt;&gt; runAsync(_FN _fn, _ARGS... _args) { \tfunction&lt;_R()&gt; rfn = std::bind(_fn,_args...);   \tshared_ptr&lt;AData&lt;_R&gt;&gt; pData(new AData&lt;_R&gt;()); \tfn_type fn = [=]() \t{ \t\tpData-&gt;data = rfn(); \t\tpData-&gt;ready = true; \t}; \tgetFreeWorker()-&gt;appendFn(fn); \treturn pData; } <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0442\u0430\u043a \u0436\u0435 \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e bind&#8217;a \u0432 \u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u044f\u043c\u0431\u0434\u044b \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 void() \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0435 \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u044f\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">double foo()\t\t\t\t\t {  \treturn 14.5; }  int sum(int a, int b) { \treturn a+b; }  int main() { \tThreadPool pool;  \tstd::function&lt;std::string(int,int)&gt; myFn = [&](int a, int b) \t{  \t\tstd::string str = &quot;String = &quot; + std::to_string(a)+&quot; &quot;+std::to_string(b); \t\treturn str; \t};  \tauto r1 = pool.runAsync&lt;double&gt;(&foo); \tauto r2 = pool.runAsync&lt;int&gt;(&sum,100,54); \tauto r3 = pool.runAsync&lt;bool&gt;([](){ return true; }); \tauto r4 = pool.runAsync&lt;std::string&gt;(myFn,50,20);  \twhile (!r1-&gt;ready);  \/\/ \u0416\u0434\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \tstd::cout &lt;&lt; r1-&gt;data &lt;&lt; std::endl; \twhile (!r2-&gt;ready);  \tstd::cout &lt;&lt; r2-&gt;data &lt;&lt; std::endl; \twhile (!r3-&gt;ready);  \tstd::cout &lt;&lt; r3-&gt;data &lt;&lt; std::endl; \twhile (!r4-&gt;ready);  \tstd::cout &lt;&lt; r4-&gt;data &lt;&lt; std::endl;  \treturn 0; } <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<br \/>  14.5<br \/>  154<br \/>  1<br \/>  String = 50 20  <\/div>\n<\/div>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">template&lt;class _R, class... _FN_ARGS, class... _ARGS&gt; shared_ptr&lt;AData&lt;_R&gt;&gt; runAsync(_R (*_fn)(_FN_ARGS...), _ARGS... _args) { \tfunction&lt;_R()&gt; rfn = std::bind(_fn,_args...);   \tshared_ptr&lt;AData&lt;_R&gt;&gt; pData(new AData&lt;_R&gt;()); \tfn_type fn = [=]() \t{ \t\tpData-&gt;data = rfn(); \t\tpData-&gt;ready = true; \t}; \tgetFreeWorker()-&gt;appendFn(fn); \treturn pData; } <\/code><\/pre>\n<p>  \u041d\u043e \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442. <br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 __thiscall. \u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432, \u043b\u044f\u043c\u0431\u0434 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u0435\u043d, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u0440\u0430\u0437\u0443 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0441\u044f \u043d\u0430 VS 2012.<br \/>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u0442\u044c <a href=\"http:\/\/pastebin.com\/MpGfkE3w\">\u0442\u0443\u0442<\/a>. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/188234\/\"> http:\/\/habrahabr.ru\/post\/188234\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043e\u0431\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a! \u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 MMORPG. \u0412 \u0438\u0433\u0440\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 \u0434\u0432\u0438\u0436\u043e\u043a, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041d\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0432\u0430\u043d\u0438\u0435 XML \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0438 \u0442.\u0434. \u0418 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0438\u0433\u0440\u044b \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f fps.<br \/>  \u0412\u043e\u043e\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0433\u0443\u0433\u043b\u043e\u043c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043e \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 <s>\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 <\/s> ThreadPool. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0438 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0441 \u0432\u0430\u043c\u0438. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-188234","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/188234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188234"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/188234\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}