<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>That's just library, not built into language. You can do it with
      forkIO as I do it per specifics</p>
    <p>of application.</p>
    <p>Greets,<br>
      Branimir.<br>
    </p>
    <div class="moz-cite-prefix">On 3/18/20 11:06 AM, YueCompl wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:8D29ADE0-2219-4E4B-9E09-2F3345B4CD4F@icloud.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      No, not to cancel a thread, but the business task on that thread's
      way ahead.  That's what Go's Context is designed for.
      <div class="">
        <div class=""><br class="">
          <div class="">
            <ul style="box-sizing: border-box; padding-left: 2em;
              margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41,
              46); font-family: -apple-system, system-ui, "Segoe
              UI", Helvetica, Arial, sans-serif, "Apple Color
              Emoji", "Segoe UI Emoji"; font-size: 16px;
              font-variant-ligatures: normal; orphans: 2; widows: 2;
              background-color: rgb(255, 255, 255);" class="">
              <li style="box-sizing: border-box;" class="">About <span
                  style="box-sizing: border-box; font-weight: 600;"
                  class="">Go</span> context from: <a
                  href="https://blog.golang.org/context" rel="nofollow"
                  style="box-sizing: border-box; background-color:
                  initial; color: rgb(3, 102, 214); text-decoration:
                  none;" class="" moz-do-not-send="true">https://blog.golang.org/context</a></li>
            </ul>
            <blockquote style="box-sizing: border-box; margin: 0px 0px
              16px; padding: 0px 1em; color: rgb(106, 115, 125);
              border-left-width: 0.25em; border-left-style: solid;
              border-left-color: rgb(223, 226, 229); font-family:
              -apple-system, system-ui, "Segoe UI", Helvetica,
              Arial, sans-serif, "Apple Color Emoji",
              "Segoe UI Emoji"; font-size: 16px;
              font-variant-ligatures: normal; orphans: 2; widows: 2;
              background-color: rgb(255, 255, 255);" class="">
              <p style="box-sizing: border-box; margin-top: 0px;
                margin-bottom: 16px;" class="">At Google, we require
                that Go programmers pass a Context parameter as the
                first argument to every function on the call path
                between incoming and outgoing requests. This allows Go
                code developed by many different teams to interoperate
                well. It provides simple control over timeouts and
                cancelation and ensures that critical values like
                security credentials transit Go programs properly.</p>
              <div style="box-sizing: border-box; margin-top: 0px;
                margin-bottom: 0px;" class="">Server frameworks that
                want to build on Context should provide implementations
                of Context to bridge between their packages and those
                that expect a Context parameter. Their client libraries
                would then accept a Context from the calling code. By
                establishing a common interface for request-scoped data
                and cancelation, Context makes it easier for package
                developers to share code for creating scalable services.</div>
            </blockquote>
            <div>I (and seems Windows api too) strongly agree that
              cancelling a thread is problematic:</div>
            <div><br class="">
            </div>
            <div><a
href="https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread"
                class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread</a></div>
            <div>
              <p style="box-sizing: inherit; margin: 1rem 0px 0px;
                padding: 0px; overflow-wrap: break-word; color: rgb(227,
                227, 227); font-family: "Segoe UI", SegoeUI,
                "Segoe WP", "Helvetica Neue",
                Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;
                font-variant-ligatures: normal; orphans: 2; widows: 2;
                background-color: rgb(23, 23, 23);" class=""><span
                  style="box-sizing: inherit;" class="">TerminateThread</span> is
                a dangerous function that should only be used in the
                most extreme cases. You should call <span
                  style="box-sizing: inherit;" class="">TerminateThread</span> only
                if you know exactly what the target thread is doing, and
                you control all of the code that the target thread could
                possibly be running at the time of the termination. For
                example, <span style="box-sizing: inherit;" class="">TerminateThread</span> can
                result in the following problems:</p>
              <ul style="box-sizing: inherit; margin: 16px 0px 16px
                38px; padding: 0px; list-style: none; color: rgb(227,
                227, 227); font-family: "Segoe UI", SegoeUI,
                "Segoe WP", "Helvetica Neue",
                Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;
                font-variant-ligatures: normal; orphans: 2; widows: 2;
                background-color: rgb(23, 23, 23);" class="">
                <li style="box-sizing: inherit; margin: 0px; padding:
                  0px; outline: 0px; list-style: outside none disc;"
                  class="">If the target thread owns a critical section,
                  the critical section will not be released.</li>
                <li style="box-sizing: inherit; margin: 0px; padding:
                  0px; outline: 0px; list-style: outside none disc;"
                  class="">If the target thread is allocating memory
                  from the heap, the heap lock will not be released.</li>
                <li style="box-sizing: inherit; margin: 0px; padding:
                  0px; outline: 0px; list-style: outside none disc;"
                  class="">If the target thread is executing certain
                  kernel32 calls when it is terminated, the kernel32
                  state for the thread's process could be inconsistent.</li>
                <li style="box-sizing: inherit; margin: 0px; padding:
                  0px; outline: 0px; list-style: outside none disc;"
                  class="">If the target thread is manipulating the
                  global state of a shared DLL, the state of the DLL
                  could be destroyed, affecting other users of the DLL.</li>
              </ul>
              <div class=""><br class="">
              </div>
            </div>
            <div>
              <blockquote type="cite" class="">
                <div class="">On 2020-03-18, at 17:16, Branimir
                  Maksimovic <<a
                    href="mailto:branimir.maksimovic@gmail.com" class=""
                    moz-do-not-send="true">branimir.maksimovic@gmail.com</a>>
                  wrote:</div>
                <br class="Apple-interchange-newline">
                <div class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=UTF-8" class="">
                  <div class="">
                    <p class="">I'm pretty sure you can't cancel
                      goroutine. Actually I have <br class="">
                    </p>
                    <p class="">very bad experience with thread
                      cancelation. Therefore flags</p>
                    <p class="">passed via channels/mvars or shared
                      flags are used to stop</p>
                    <p class="">threads. <br class="">
                    </p>
                    <p class="">Greets,<br class="">
                      Branimir.<br class="">
                    </p>
                    <div class="moz-cite-prefix">On 3/18/20 10:10 AM,
                      YueCompl wrote:<br class="">
                    </div>
                    <blockquote type="cite"
                      cite="mid:3B0EBA42-ECA4-482A-9675-3166CFB54454@icloud.com"
                      class="">
                      <meta http-equiv="Content-Type"
                        content="text/html; charset=UTF-8" class="">
                      Idiomatic resource leakage prevention in short.
                      <div class=""><br class="">
                        <div class="">An app wants to be as responsive
                          to its users as practically feasible, it would
                          try multiple paths to load-balanced resources,
                          and use the first response that come back,
                          then cancel other paths. Cancellation can help
                          reducing vain computation in such
                          architectures, sometimes largely enough.<br
                            class="">
                          <div class=""><br class="">
                            <blockquote type="cite" class="">
                              <div class="">On 2020-03-18, at 16:58,
                                Branimir Maksimovic <<a
                                  href="mailto:branimir.maksimovic@gmail.com"
                                  class="" moz-do-not-send="true">branimir.maksimovic@gmail.com</a>>
                                wrote:</div>
                              <br class="Apple-interchange-newline">
                              <div class="">
                                <meta http-equiv="Content-Type"
                                  content="text/html; charset=UTF-8"
                                  class="">
                                <div class="">
                                  <p class="">What's wrong with forkIO?</p>
                                  <p class="">Greets,<br class="">
                                    Branimir.<br class="">
                                  </p>
                                  <div class="moz-cite-prefix">On
                                    3/18/20 9:37 AM, YueCompl via
                                    Haskell-Cafe wrote:<br class="">
                                  </div>
                                  <blockquote type="cite"
                                    cite="mid:B35ABE4A-57B5-4834-9DCE-EBFF5531A07F@icloud.com"
                                    class="">
                                    <meta http-equiv="Content-Type"
                                      content="text/html; charset=UTF-8"
                                      class="">
                                    If not for tight loops or other CPU
                                    intensive tasks, you may be
                                    interested in Edh, which introduces
                                    Go's goroutine to GHC runtime. But
                                    Edh threads add much higher overhead
                                    on top of GHC threads, so there's a
                                    price to pay for simplicity of end
                                    programmer's job.
                                    <div class=""><br class="">
                                    </div>
                                    <div class="">It's briefly described
                                      at <a
href="https://github.com/e-wrks/edh/tree/master/Tour#program--threading-model"
                                        class="" moz-do-not-send="true">https://github.com/e-wrks/edh/tree/master/Tour#program--threading-model</a> .
                                      This is very new and I'm right now
                                      actively working on it for PoC of
                                      an STM powered in-memory graph
                                      database implementation.</div>
                                    <div class=""><br class="">
                                    </div>
                                    <div class="">Best regards,</div>
                                    <div class="">Compl<br class="">
                                      <div class=""><br class="">
                                        <blockquote type="cite" class="">
                                          <div class="">On 2020-03-18,
                                            at 11:15, Niklas Hambüchen
                                            <<a
                                              href="mailto:mail@nh2.me"
                                              class=""
                                              moz-do-not-send="true">mail@nh2.me</a>>
                                            wrote:</div>
                                          <br
                                            class="Apple-interchange-newline">
                                          <div class="">
                                            <div class="">I've you're
                                              new to async, also check
                                              out my recent rework of
                                              the docs that talk about
                                              this topic specifically:<br
                                                class="">
                                              <br class="">
                                              <a
                                                href="https://github.com/simonmar/async/pull/105/files"
                                                class=""
                                                moz-do-not-send="true">https://github.com/simonmar/async/pull/105/files</a><br
                                                class="">
                                              <br class="">
                                              (To be available in the
                                              next release of async.)<br
                                                class="">
_______________________________________________<br class="">
                                              Haskell-Cafe mailing list<br
                                                class="">
                                              To (un)subscribe, modify
                                              options or view archives
                                              go to:<br class="">
                                              <a
                                                class="moz-txt-link-freetext"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
                                                moz-do-not-send="true">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br
                                                class="">
                                              Only members subscribed
                                              via the mailman list are
                                              allowed to post.</div>
                                          </div>
                                        </blockquote>
                                      </div>
                                      <br class="">
                                    </div>
                                    <br class="">
                                    <fieldset
                                      class="mimeAttachmentHeader"></fieldset>
                                    <pre class="moz-quote-pre" wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" moz-do-not-send="true">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
                                  </blockquote>
                                </div>
_______________________________________________<br class="">
                                Haskell-Cafe mailing list<br class="">
                                To (un)subscribe, modify options or view
                                archives go to:<br class="">
                                <a
                                  href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
                                  class="" moz-do-not-send="true">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br
                                  class="">
                                Only members subscribed via the mailman
                                list are allowed to post.</div>
                            </blockquote>
                          </div>
                          <br class="">
                        </div>
                      </div>
                    </blockquote>
                  </div>
                </div>
              </blockquote>
            </div>
            <br class="">
          </div>
        </div>
      </div>
    </blockquote>
  </body>
</html>