{"id":710,"date":"2014-09-26T17:21:23","date_gmt":"2014-09-26T09:21:23","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=710"},"modified":"2014-09-26T17:21:23","modified_gmt":"2014-09-26T09:21:23","slug":"qworker%e6%9b%b4%e6%96%b0-%e5%a2%9e%e5%8a%a0%e6%9e%9a%e4%b8%be%e4%bd%9c%e4%b8%9a%e7%8a%b6%e6%80%81%e6%9e%9a%e4%b8%be%e5%87%bd%e6%95%b0%e7%ad%89%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=710","title":{"rendered":"QWorker\u66f4\u65b0-\u589e\u52a0\u679a\u4e3e\u4f5c\u4e1a\u72b6\u6001\u679a\u4e3e\u51fd\u6570\u7b49\u529f\u80fd"},"content":{"rendered":"<p>QWorker\u4eca\u5929\u66f4\u65b0\u4e86\u51e0\u4e2a\u66f4\u65b0\u7684\u529f\u80fd\uff1a<\/p>\n<p>1\u3001\u65b0\u589e\u4e86\u4e00\u4e2aEnumWorkerStatus\u51fd\u6570\u6765\u679a\u4e3e\u6240\u6709\u5de5\u4f5c\u8005\u7684\u72b6\u6001\uff0c\u65b9\u4fbf\u4f60\u4e86\u89e3\u6bcf\u4e2a\u4f5c\u4e1a\u51fd\u6570\u5728\u5fd9\u5565\u3002\u5728\u7a0b\u5e8f\u53d1\u751f\u6b7b\u9501\u65f6\uff0c\u65b9\u4fbf\u4f60\u627e\u5230\u6b7b\u9501\u7684\u5730\u65b9\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u8c03\u7528\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TForm1.Button32Click(Sender: TObject);\r\nvar\r\n  AStatus:TQWorkerStatus;\r\n  I: Integer;\r\n  S:String;\r\nbegin\r\nAStatus:=Workers.EnumWorkerStatus;\r\nfor I := Low(AStatus) to High(AStatus) do\r\n  begin\r\n  S:=S+'\u3010\u5de5\u4f5c\u8005 '+IntToStr(I)+'(ID='+IntToStr(AStatus[I].ThreadId)+')\u3011'#13#10+\r\n    ' \u5df2\u5904\u7406:'+IntToStr(AStatus[I].Processed)+' \u72b6\u6001:';\r\n  if AStatus[I].IsIdle then\r\n    S:=S+'\u7a7a\u95f2'#13#10#13#10\r\n  else\r\n    begin\r\n    S:=S+'\u5fd9\u788c(\u4f5c\u4e1a:'+AStatus[I].ActiveJob+')'#13#10;\r\n    if Length(AStatus[I].Stacks)&gt;0 then\r\n      S:=S+' \u5806\u6808:'#13#10+AStatus[I].Stacks+#13#10#13#10\r\n    else\r\n      S:=S+#13#10;\r\n    end;\r\n  end;\r\nShowMessage(S);\r\nend;<\/pre>\n<p>\u6267\u884c\u6548\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2014\/09\/QWorker_EnumWorkerStatus.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-711\" src=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2014\/09\/QWorker_EnumWorkerStatus-300x222.jpg\" alt=\"QWorker_EnumWorkerStatus\" width=\"300\" height=\"222\" srcset=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2014\/09\/QWorker_EnumWorkerStatus-300x222.jpg 300w, https:\/\/blog.qdac.cc\/wp-content\/uploads\/2014\/09\/QWorker_EnumWorkerStatus.jpg 412w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>2\u3001\u65b0\u589e\u4e86\u4e00\u4e2a\u540e\u53f0\u4f4e\u4f18\u5148\u7ea7\u7684\u7edf\u8ba1\u7ebf\u7a0b\uff0c\u6bcf\u79d2\u4f1a\u68c0\u67e5\u4e00\u4e2aCPU\u5360\u7528\u7387\uff0c\u5982\u679cCPU\u5360\u7528\u7387\u4f4e\u4e8e60%\uff0c\u4e14\u7cfb\u7edf\u4e2d\u6709\u9700\u8981\u7acb\u5373\u5904\u7406\u7684\u4f5c\u4e1a\u65f6\uff0c\u4f1a\u5c1d\u8bd5\u89e6\u53d1\u65b0\u7684\u5de5\u4f5c\u8005\uff0c\u4ee5\u4fbf\u5c3d\u5feb\u5904\u7406\u4f5c\u4e1a\u3002<\/p>\n<p>3\u3001\u4fee\u6b63\u4e86\u591a\u4e2a\u5728\u7279\u5b9a\u60c5\u5f62\u4e0b\uff0c\u5b9a\u65f6\u4f5c\u4e1a\u53ef\u80fd\u4f1a\u4ea7\u751f\u4e0d\u5fc5\u8981\u7684\u5ef6\u8fdf\u7684\u95ee\u9898\u3002<\/p>\n<h4>\u3010\u95ee\u9898\u63cf\u8ff0\u3011<\/h4>\n<p>\u521b\u5efa\u591a\u4e2a\u5b9a\u65f6\u4f5c\u4e1a\u65f6\uff0c\u5982\u679c\u8fd9\u591a\u4e2a\u4f5c\u4e1a\u89e6\u53d1\u7684\u65f6\u95f4\u70b9\u91cd\u590d\uff0c\u800c\u8fd9\u4e2a\u4f5c\u4e1a\u5904\u7406\u65f6\u95f4\u8f83\u957f\u65f6\uff0c\u4f1a\u89e6\u53d1\u672c\u95ee\u9898\u3002\u8fd9\u662f\u7531\u4e8e\u7cfb\u7edf\u4fdd\u7559\u7684\u5de5\u4f5c\u8005\u6570\u91cf\u90fd\u88ab\u53bb\u7528\u4e8e\u5904\u7406\u4f5c\u4e1a\uff0c\u4f46\u5374\u672a\u53ca\u65f6\u96c7\u4f63\u65b0\u7684\u5de5\u4f5c\u8005\u9020\u6210\u7684\u3002<\/p>\n<h4>\u3010\u4e25\u91cd\u7ea7\u522b\u3011<\/h4>\n<p>\u9ad8<\/p>\n<h4>\u3010\u66f4\u65b0\u7ea7\u522b\u3011<\/h4>\n<p>\u7acb\u5373\u66f4\u65b0<\/p>\n<h4>\u3010\u7279\u522b\u611f\u8c22\u3011<\/h4>\n<p>\u4e0d\u597d\u610f\u601d\uff0c\u8fd9\u4e2a\u95ee\u9898\u6211\u5fd8\u4e86\u90a3\u4f4d\u7fa4\u53cb\u62a5\u544a\uff0c\u5728\u6b64\u81f4\u6b49\u517c\u81f4\u8c22\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>QWorker\u4eca\u5929\u66f4\u65b0\u4e86\u51e0\u4e2a\u66f4\u65b0\u7684\u529f\u80fd\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,6,2],"tags":[],"class_list":["post-710","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-qworker","category-update"],"views":3485,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=710"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}