Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat libraries should I use for better OCaml Threading?
    primarykey
    data
    text
    <p>I have asked a related question before <a href="https://stackoverflow.com/questions/16342840/why-ocamls-threading-is-considered-as-not-enough">Why OCaml&#39;s threading is considered as `not enough`?</a></p> <p>No matter how "bad" ocaml's threading is, I notice some libraries say they can do real threading.</p> <p>For example, <strong>Lwt</strong></p> <blockquote> <p>Lwt offers a new alternative. It provides very light-weight cooperative threads; ``launching'' a thread is a very fast operation, it does not require a new stack, a new process, or anything else. Moreover context switches are very fast. In fact, it is so easy that we will launch a thread for every system call. And composing cooperative threads will allow us to write highly asynchronous programs.</p> </blockquote> <p>Also <code>Jane Street</code>'s <strong>aync_core</strong> also provides similar things, if I am right.</p> <hr> <p>But I am quite confused. Do <code>Lwt</code> or <code>aync_core</code> provide threading like <code>Java threading</code>?</p> <p>If I use them, can I utilise multiple cpu?</p> <p><strong>In what way, can I get a "real threading" (just like in Java) in OCaml?</strong></p> <hr> <p><strong>Edit</strong></p> <p>I am still confused.</p> <p>Let me add a scenario:</p> <p>I have a server (<code>16 cpu cores</code>) and a server application.</p> <p>What the server application does are:</p> <ul> <li>It listens to requests</li> <li>For each request, it starts a computational task (let's say costs 2 minutes to finish)</li> <li>When each task finishes, the task will either return the result back to the main or just send the result back to client directly</li> </ul> <hr> <p>In Java, it is very easy. I create a thread pool, then for each request, I create a thread in that pool. that thread will run the computational task. This is mature in Java and it can utilize the 16 cpu cores. Am I right?</p> <p><strong>So my question is: can I do the same thing in OCaml?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload