Questions tagged [lwt]

LWT, usually referring to lightweight threads, is a poorly defined term. Prefer instead to use [ocaml-lwt] for the OCaml library, [lightweight-processes], [green-threads] or one of the more specific tags listed in the tag wiki.

The term "lightweight threads" is poorly defined and might refer to a number of different concepts. Prefer instead to use one of these tags:

26 questions
7
votes
1 answer

Cassandra LWT reads

It's my understanding that LWT inserts are always done with SERIAL consistency level. If true, does that mean that reading a row inserted as LWT, can be safely read with a consistency level of ANY? In other words, I assume an LWT insert is fully…
nilskp
  • 3,097
  • 1
  • 30
  • 34
5
votes
2 answers

Why is this Lwt based and seemingly concurrent code so inconsistent

I am trying to create concurrent examples of Lwt and came up with this little sample let () = Lwt_main.run ( let start = Unix.time () in Lwt_io.open_file Lwt_io.Input "/dev/urandom" >>= fun data_source -> Lwt_unix.mkdir "serial"…
user1971598
3
votes
0 answers

^C while process is doing an Lwt read

I'm working on a little program using Lwt_io.read_into_exactly and other functions from Lwt_io. It all works great, but ^C (sigint) doesn't do anything, which forces me to kill -9 everytime I'm testing it, it's a bit annoying. Is there something I…
Ulrar
  • 895
  • 8
  • 17
3
votes
2 answers

OCaml: Lwt and non blocking socket

I wanted to try the Lwt_unix module for a simple client that reads data in a socket until there is nothing to read. Some told me that Lwt create non blocking sockets but with my code, it is still blocking: open Lwt open Unix (* ocamlfind ocamlc -o…
cedlemo
  • 3,205
  • 3
  • 32
  • 50
3
votes
1 answer

How to combine Lwt filters?

I am currently learning Lwt. I am interested into using asynchronous processes to replace some shell routines by OCaml routines. Let us take a look at a simplified first attempt, where a filter is created by combining two threads running cat: let…
Michaël Le Barbier
  • 6,103
  • 5
  • 28
  • 57
2
votes
1 answer

Lwt 2.7.0 type error

I wrote this piece of code with Lwt 2.7.0 : open Lwt let listen_address = Unix.inet_addr_loopback let port = 9000 let backlog = 1 let () = Lwt_log.add_rule "*" Lwt_log.Info let create_socket () = let open Lwt_unix in let sock = socket PF_INET…
Lhooq
  • 4,281
  • 1
  • 18
  • 37
2
votes
1 answer

How the LWT- Light Weight Transaction is working when we use IF NOT EXIST?

The question is that, When we use INSERT INTO USERS (login, email, name, login_count) values ('jbellis', 'jbellis@datastax.com', 'Jonathan Ellis', 1) IF NOT EXISTS in IF NOT EXIST exactly which columns are compared…
Elnaz
  • 2,854
  • 3
  • 29
  • 41
2
votes
1 answer

OCaml lwt utop infix bind operator >>= is missing

I call require "lwt.simple-top" ;; on utop and try a simple example but it is not able to find the operator >>=.
Sanfer
  • 414
  • 5
  • 16
2
votes
2 answers

Ocaml Lwl_mvar.take does not block thread

I'm still going on writing a simple game server. Due to a piece of advice from here I implemented mvar support in hope it will block threads while does not contain at least 2 players. But it doesn't wait untill I put any data there. It's always…
2
votes
1 answer

Ocaml Lwt - some implementations of multiplayer game

I'm going on to writing a simple implementation of tic-tac-toe server (via telnet). The task - players connect to server and after they send START the server looks for a partner who typed START too, and game begins. A piece of code: let…
2
votes
1 answer

making OPAM work with system compiler under MacOS X

I am trying to do a very basic installation of OPAM under MacOS. Using macports I've installed following packages: opam @1.2.0 ocaml-findlib @1.5.5 ocaml-camlp4 @4.02.0.1_1 when I did opam init (not as root, since I only need it for one…
krokodil
  • 1,326
  • 10
  • 18
1
vote
1 answer

Lwt promise local storage, is it possible?

I'm building an application using Lwt, and it would be nice for me to be able to have some sort of context, or promise local static storage for the life cycle of the promise. Is there any way to do this? Ideally it could be a simple Map that is…
Rawley Fowler
  • 1,366
  • 7
  • 15
1
vote
1 answer

Terminate an Lwt thread from another thread

Here I have a function which accept a TCP connection and run two Lwt threads handle_connection and send_message. Each time that a connection is terminated I am notified in the handle_connection thread, so I can terminate it loops, but then I want to…
1
vote
1 answer

Canceling a Lwt. thread

I can't for the life of me find a way to handle the canceling of an lwt thread. Here is what I have, simplified. #require "lwt.unix, lwt.ppx" open Lwt.Infix let program = let counter = ref 1 in let can_cancel = fst (Lwt.task ()) in …
user1971598
1
vote
1 answer

Proper use of Lwt_main.run()

I have encountered some errors when using Lwt_main.run(). Basically I have two infinite loops with type unit -> 'a Lwt.t = and when I start both loops I receive errors. I am using these in the context that one loop is a writer loop and the…
Thomas
  • 347
  • 3
  • 19
1
2