{"id":5184,"date":"2020-03-19T22:14:38","date_gmt":"2020-03-19T14:14:38","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=5184"},"modified":"2020-03-19T22:14:40","modified_gmt":"2020-03-19T14:14:40","slug":"%e6%95%99%e7%a8%8bqworker-%e4%b8%ad%e5%a6%82%e4%bd%95%e5%8a%a8%e6%80%81%e4%bf%ae%e6%94%b9%e9%87%8d%e5%a4%8d%e5%bb%b6%e8%bf%9f%e4%bd%9c%e4%b8%9a%e7%9a%84%e5%bb%b6%e8%bf%9f%e9%97%b4%e9%9a%94","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=5184","title":{"rendered":"[\u6559\u7a0b]QWorker \u4e2d\u5982\u4f55\u52a8\u6001\u4fee\u6539\u91cd\u590d\u5ef6\u8fdf\u4f5c\u4e1a\u7684\u5ef6\u8fdf\u95f4\u9694"},"content":{"rendered":"\n<p>\u4e00\u822c\u7684\u5ef6\u8fdf\u91cd\u590d\u4f5c\u4e1a\u7684\u76f4\u63a5\u8c03\u7528 Delay \u65f6\uff0c\u6307\u5b9a\u95f4\u9694\u65f6\u95f4\u548c\u91cd\u590d\u53c2\u6570\uff0c\u5c31\u53ef\u4ee5\u81ea\u52a8\u542f\u52a8\u4e86\u91cd\u590d\u7684\u5ef6\u8fdf\u4f5c\u4e1a\u3002\u4f46\u9ed8\u8ba4\u60c5\u51b5\u4e0a\uff0c\u8fd9\u4e2a\u5ef6\u8fdf\u4f5c\u4e1a\u7684\u95f4\u9694\u65f6\u957f\u662f\u56fa\u5b9a\u7684\uff0c\u8981\u52a8\u6001\u4fee\u6539\u8fd9\u4e2a\u65f6\u957f\uff0c\u6211\u4eec\u53ef\u4ee5\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p>1\u3001\u4fee\u6539\u4f5c\u4e1a\u5bf9\u8c61\u5b9e\u4f8b\u7684 Source.FirstDelay \u53c2\u6570\u7684\u503c\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Workers.Delay(\n  procedure (AJob:PQJob)\n  begin\n    ...\n    AJob.Source.FirstDelay:=\u65b0\u7684\u5ef6\u8fdf\u65f6\u95f4;\n    ...\n  end,Q1Second,nil,false,jdfFreeByUser,true);<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f FirstDelay \u7684\u65f6\u95f4\u7cbe\u5ea6\u662f 0.1ms\uff0c\u5efa\u8bae\u4f7f\u7528 Q1Second*5 \u8fd9\u6837\u7684\u65b9\u5f0f\u6765\u6307\u5b9a\u65f6\u957f\u3002<\/p>\n\n\n\n<p>2\u3001\u4f7f\u7528 Delay+Delay \u7684\u65b9\u6cd5\u6765\u4fee\u6539\u65f6\u957f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5b9e\u9645\u4e0a\u901a\u8fc7\u6295\u9012\u65b0\u7684\u5ef6\u8fdf\u4f5c\u4e1a\u6765\u5b9e\u73b0\u4e0d\u5b9a\u957f\u5ef6\u8fdf\u7684\u76ee\u6807\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Workers.Delay(\n  procedure (AJob:PQJob)\n  begin\n    Workers.Delay(TQJobProcA(AJob.WorkerProc.ProcA),Q1Second*(1+random(10)),AJob.Data,AJob.InMainThread,AJob.FreeType,false);\n    DebugOut('%s fired',&#91;FormatDateTime('yyyy-mm-dd hh:nn:ss',Now)]);\n  end,Q1Second,nil);<\/code><\/pre>\n\n\n\n<p>\u56e0\u4e3a\u662f\u533f\u540d\u4f5c\u4e1a\uff0c\u6ca1\u6709\u51fd\u6570\u540d\uff0c\u4f46\u4f60\u53ef\u4ee5\u901a\u8fc7 AJob.WorkerProc.ProcA \u83b7\u53d6\u5230\u5b83\u7684\u4f5c\u4e1a\u533f\u540d\u51fd\u6570\u7684\u5b9e\u4f8b\u5730\u5740\uff0c\u505a\u4e3a\u53c2\u6570\u4f20\u9012\u8fdb\u53bb\uff0c\u4ece\u800c\u5b9e\u73b0\u91cd\u590d\u6295\u9012\u4f5c\u4e1a\u7684\u76ee\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u822c\u7684\u5ef6\u8fdf\u91cd\u590d\u4f5c\u4e1a\u7684\u76f4\u63a5\u8c03\u7528 Delay [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","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":[8],"tags":[780,779,449,781],"class_list":["post-5184","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-delay","tag-qdac","tag-qworker","tag-781"],"views":2943,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5184","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=5184"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5184\/revisions"}],"predecessor-version":[{"id":5185,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5184\/revisions\/5185"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}