ocamlocsigen

Does Lwt mean "Light Weight Thread"?


I have been testing ocsigen which uses Lwt. I guess Lwt means "Light Weight Thread",right? If so, how can we call it "light weight" ?

It seems Lwt is using OS's thread which is NOT light (compared with Erlang and Haskell).

Please shed a light on me, thanks!


Solution

  • The documentation page for Lwt says:

    [Lwt] 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.