<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>faith_and_brave</author_name>
  <author_url>https://blog.hatena.ne.jp/faith_and_brave/</author_url>
  <blog_title>Faith and Brave - C++で遊ぼう</blog_title>
  <blog_url>https://faithandbrave.hateblo.jp/</blog_url>
  <categories>
    <anon>C++</anon>
  </categories>
  <description>C++20で導入されたstd::jthreadは、スレッドを中断させる仕組みをもった便利なクラスです。今回は、C++14でそれを簡易的に実装してみました (C++14の機能としてはラムダ式の初期化キャプチャを使っています。ラムダ式に外の変数をムーブするために必要)。 std::thread + std::promiseとstd::futureを使えばできます。 std::promiseに値を設定することで中断リクエストし、スレッド側のstd::futureはstd::promiseに値が設定されるまで (中断リクエストされるまで) 処理を続けます。 std::promiseには1回しか値を設定…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ffaithandbrave.hateblo.jp%2Fentry%2F2022%2F09%2F01%2F034015&quot; title=&quot;jthreadを簡易実装する - Faith and Brave - C++で遊ぼう&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2022-09-01 03:40:15</published>
  <title>jthreadを簡易実装する</title>
  <type>rich</type>
  <url>https://faithandbrave.hateblo.jp/entry/2022/09/01/034015</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
