sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
dark_light has quit [Connection timed out]
Submarine has joined #ocaml
ChoJin has quit ["This computer has gone to sleep"]
Amorphous has quit [Connection timed out]
Amorphous has joined #ocaml
tuor has left #ocaml []
asmanian has quit ["Verlassend"]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
bzzbzz has joined #ocaml
johnnowak has quit []
rillig has quit ["exit(EXIT_SUCCESS)"]
jlouis has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
slowriot has joined #ocaml
b00t has joined #ocaml
whatsup103 has quit [Read error: 104 (Connection reset by peer)]
johnnowak has joined #ocaml
pants1 has quit [Read error: 110 (Connection timed out)]
pstickne has quit [Read error: 104 (Connection reset by peer)]
slowriot has quit [Read error: 104 (Connection reset by peer)]
pstickne has joined #ocaml
jlouis has quit [Read error: 145 (Connection timed out)]
johnnowak has quit []
b00t has quit [Remote closed the connection]
johnnowak has joined #ocaml
mbishop has joined #ocaml
b00t has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
piggybox has joined #ocaml
ludwig- has joined #ocaml
smimp has joined #ocaml
johnnowak has quit []
pants1 has joined #ocaml
smimou has joined #ocaml
jlouis has joined #ocaml
pango is now known as pangoafk
ChoJin has joined #ocaml
smimou has quit ["bli"]
pants1 has quit [Remote closed the connection]
asmanian has joined #ocaml
love-pingoo has joined #ocaml
ChoJin has quit ["This computer has gone to sleep"]
ChoJin has joined #ocaml
ChoJin has quit [Client Quit]
smimp is now known as smimp`sleep
love-pingoo has quit ["Leaving"]
asmanian has quit ["Verlassend"]
Submarine has quit [Remote closed the connection]
johnnowak has joined #ocaml
piggybox has quit [Connection timed out]
piggybox has joined #ocaml
<oscarh>
Hi, is there any nice way of doing a cond_timed_wait() in OCaml? It seems to be missing in the Condition module?
<flux->
unfortunately I don't think there's a good way :(
<flux->
cond_wait_multiple would be nice, too
<flux->
the thread-library lacks the composability of the Event-module :)
<flux->
s/library/module/
<flux->
I believe it could be emulated, though
<flux->
a thread that uses select to timeout or receive new instructions, and the thread could do Condition.broadcast
<flux->
I'm not exactly excited about the performance, though.. but I suppose it wouldn't be too bad, assuming communication with the thread would be asynchronous
<oscarh>
Hmm, but then i would have to create an extra thread every time I want this :/
<oscarh>
How hard would it be to wrap the cond_* functions I'm missing?
<flux->
you could have the extra thread on the background waiting for instructions
<oscarh>
Using some C glue?
<flux->
I don't know, I haven't looked
<flux->
I believe the problem is that you want to implement these for every platform (for it to be in the standard ocaml library)
<flux->
but I suppose it shouldn't be such a big of a problem
<oscarh>
Oh, I only really care about pthreads
<oscarh>
So for my sake it wouldn't be that much of a problem
<flux->
hm
<oscarh>
I guess I could also use Unix.interval_timer
<flux->
condition.ml is written in ocaml
<flux->
nice
pangoafk has quit [Remote closed the connection]
<flux->
it does 'Thread.sleep' to wait the condition
<oscarh>
But that would signal the whole thread
<oscarh>
Thread.sleep?
<oscarh>
Busy wait?
<flux->
and before that it adds itself to the condition's 'waiting'-list
<flux->
it might not be that difficult
pangoafk has joined #ocaml
<oscarh>
I'll take a look at the source of Condition then
<oscarh>
I would have assumed it used pthread's conditions...
<oscarh>
Does the behaviour change if you use native threads vs. vmthreads?
<flux->
I think you could write another version of thread_sleep
<flux->
I don't think it uses pthread's conditions, although I might be looking at the green threads implementation..
<flux->
I wonder what happens if you wake a thread that is doing Unix.sleep
romanoffi has left #ocaml []
<flux->
ok, the code was for vmthreads
<flux->
and I think it still might require some patching of ocaml library..
<oscarh>
I'm using native threads, or will be any way
<oscarh>
I'd rather write a C wrapper for pthread_cond
<oscarh>
pthread_cond_timedwait
<oscarh>
:/
<oscarh>
I'll have to run for a while
<flux->
as far as I can see, yes, it would be that simple
<flux->
infact I would have some use to such a patch too :-)
<flux->
(I've used the 'a separate thread'-approach, but it is quite complex and doesn't yet know how to use only a single thread for all timing requirements)
smergo has joined #ocaml
ikaros has quit ["Leaving"]
johnnowak has quit []
romanoffi has joined #ocaml
b00t has quit [Remote closed the connection]
<flux->
is there a way to create a 'new' object in a function? for example let foo () = [0] results in foo () == foo (), which I would like to avoid
<flux->
funny though that foo () == [0] is false
<flux->
with Obj.new_block, maybe, but that's dark magic..
<flux->
it works, though: let new_tag () : unit = Obj.obj (Obj.new_block 1 1) in let a, b = new_tag (), new_tag ();; let l = [a, "a"; b, "b"];;
<flux->
List.assq l a and List.assq l b work as expected
<flux->
however, I really should look at what I'm breaking here, possibly gc :-)
<flux->
I suppose it's either tag -> size -> t or size -> tag -> t..