Skip to content

Commit

Permalink
Site updated: 2024-06-08 18:21:58
Browse files Browse the repository at this point in the history
  • Loading branch information
wqllyx committed Jun 8, 2024
1 parent d4ce14b commit 8c14df0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions 2024/06/08/c-设计线程池(3)需求分析/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<meta property="og:site_name" content="wqllyx的网站">
<meta property="og:description" content="我们实现的是一个线程池,他是一个应用的一部分组件,可以算作一个库。并不能算作中间件。因为,他不能够独立完成一个功能或服务。 最终打包成一个动态库供别人使用。 使用方式12345678910&#x2F;&#x2F; 建立线程池对象ThreadPool pool;&#x2F;&#x2F; 选择模式,固定大小或者可变大小pool.setMode(fixed(default) | cached);&#x2F;&#x2F; 启动线程池pool.start();&#x2F;&#x2F;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/_posts/image-20240603125437820.png">
<meta property="og:image" content="http://example.com/2024/06/08/c-%E8%AE%BE%E8%AE%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%EF%BC%883%EF%BC%89%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/image-20240603125437820.png">
<meta property="article:published_time" content="2024-06-08T10:18:29.000Z">
<meta property="article:modified_time" content="2024-06-08T10:20:22.477Z">
<meta property="article:modified_time" content="2024-06-08T10:21:31.362Z">
<meta property="article:author" content="">
<meta property="article:tag" content="计算机">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/_posts/image-20240603125437820.png">
<meta name="twitter:image" content="http://example.com/2024/06/08/c-%E8%AE%BE%E8%AE%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%EF%BC%883%EF%BC%89%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/image-20240603125437820.png">

<link rel="canonical" href="http://example.com/2024/06/08/c-%E8%AE%BE%E8%AE%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%EF%BC%883%EF%BC%89%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/">

Expand Down Expand Up @@ -177,7 +177,7 @@ <h1 class="post-title" itemprop="name headline">
<span class="post-meta-item-text">发表于</span>


<time title="创建时间:2024-06-08 18:18:29 / 修改时间:18:20:22" itemprop="dateCreated datePublished" datetime="2024-06-08T18:18:29+08:00">2024-06-08</time>
<time title="创建时间:2024-06-08 18:18:29 / 修改时间:18:21:31" itemprop="dateCreated datePublished" datetime="2024-06-08T18:18:29+08:00">2024-06-08</time>
</span>


Expand All @@ -195,7 +195,7 @@ <h1 class="post-title" itemprop="name headline">
<p>最终打包成一个动态库供别人使用。</p>
<h2 id="使用方式"><a href="#使用方式" class="headerlink" title="使用方式"></a>使用方式</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 建立线程池对象</span></span><br><span class="line">ThreadPool pool;</span><br><span class="line"><span class="comment">// 选择模式,固定大小或者可变大小</span></span><br><span class="line">pool.<span class="built_in">setMode</span>(<span class="built_in">fixed</span>(<span class="keyword">default</span>) | cached);</span><br><span class="line"><span class="comment">// 启动线程池</span></span><br><span class="line">pool.<span class="built_in">start</span>();</span><br><span class="line"><span class="comment">// 提交任务到线程池,返回任务计算完成的的值(可选的返回值,也可能没有)</span></span><br><span class="line">Result result = pool.<span class="built_in">submitTask</span>(concreteTask);</span><br><span class="line"><span class="comment">// 获得最终的结果类型</span></span><br><span class="line">result.<span class="built_in">get</span>().Cast&lt;&gt;();</span><br></pre></td></tr></table></figure>

<p><img src="/../_posts/image-20240603125437820.png" alt="image-20240603125437820"></p>
<p><img src="/2024/06/08/c-%E8%AE%BE%E8%AE%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%EF%BC%883%EF%BC%89%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/image-20240603125437820.png" alt="image-20240603125437820"></p>
<p>还需要一个线程容器存放Thread对象。(也是有大小的)</p>
<p>还需要一个任务容器存放任务对象。(也是有大小的)</p>
<p>任务容器存放的是任务抽象基类(里面有一个纯虚函数run方法),以便可以存放任何任务。用户需要继承task基类来实现自己的任务。</p>
Expand Down
2 changes: 1 addition & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ pre .javascript .function {
}
.links-of-author a::before,
.links-of-author span.exturl::before {
background: #fff271;
background: #b8ff1b;
border-radius: 50%;
content: ' ';
display: inline-block;
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h2 class="post-title" itemprop="name headline">
<span class="post-meta-item-text">发表于</span>


<time title="创建时间:2024-06-08 18:18:29 / 修改时间:18:20:22" itemprop="dateCreated datePublished" datetime="2024-06-08T18:18:29+08:00">2024-06-08</time>
<time title="创建时间:2024-06-08 18:18:29 / 修改时间:18:21:31" itemprop="dateCreated datePublished" datetime="2024-06-08T18:18:29+08:00">2024-06-08</time>
</span>


Expand All @@ -191,7 +191,7 @@ <h2 class="post-title" itemprop="name headline">
<p>最终打包成一个动态库供别人使用。</p>
<h2 id="使用方式"><a href="#使用方式" class="headerlink" title="使用方式"></a>使用方式</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 建立线程池对象</span></span><br><span class="line">ThreadPool pool;</span><br><span class="line"><span class="comment">// 选择模式,固定大小或者可变大小</span></span><br><span class="line">pool.<span class="built_in">setMode</span>(<span class="built_in">fixed</span>(<span class="keyword">default</span>) | cached);</span><br><span class="line"><span class="comment">// 启动线程池</span></span><br><span class="line">pool.<span class="built_in">start</span>();</span><br><span class="line"><span class="comment">// 提交任务到线程池,返回任务计算完成的的值(可选的返回值,也可能没有)</span></span><br><span class="line">Result result = pool.<span class="built_in">submitTask</span>(concreteTask);</span><br><span class="line"><span class="comment">// 获得最终的结果类型</span></span><br><span class="line">result.<span class="built_in">get</span>().Cast&lt;&gt;();</span><br></pre></td></tr></table></figure>

<p><img src="/../_posts/image-20240603125437820.png" alt="image-20240603125437820"></p>
<p><img src="/2024/06/08/c-%E8%AE%BE%E8%AE%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%EF%BC%883%EF%BC%89%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/image-20240603125437820.png" alt="image-20240603125437820"></p>
<p>还需要一个线程容器存放Thread对象。(也是有大小的)</p>
<p>还需要一个任务容器存放任务对象。(也是有大小的)</p>
<p>任务容器存放的是任务抽象基类(里面有一个纯虚函数run方法),以便可以存放任何任务。用户需要继承task基类来实现自己的任务。</p>
Expand Down

0 comments on commit 8c14df0

Please sign in to comment.