<EliasAmaral>
tsuyoshi, i think the program isn't allowed to exit without flushing stdout
[azoic] has joined #ocaml
<tsuyoshi>
hmm the other thing is, you aren't waiting for the threads to complete before exiting
<tsuyoshi>
try joining the threads
<EliasAmaral>
but when the computation of _ finalizes, the other threads are floating around, so the program shouldn't be allowed to exit either. (that is, i think a program may exit only if it has no running threads)
<EliasAmaral>
hmm
<tsuyoshi>
I don't think so
<tsuyoshi>
if you exit it should just kill the remaining threads.. but then the documentation doesn't say one way or the other
<EliasAmaral>
but if there are running threads, the termination of _ doesn't actually mean an "exit"..
<tsuyoshi>
it doesn't?
<EliasAmaral>
i think if the main thread dies, another thread becomes the "main thread".. or, better, there are no main thread
<EliasAmaral>
o.o
<EliasAmaral>
btw, the interactive interpreter outputs the ha! and hu!
<beterraba>
hello. Does someone knows about surreal numbers or where can i find some implementation for it in SML/NJ , ML or oCAML?
seafoodX has joined #ocaml
threeve has left #ocaml []
Demitar has quit [Read error: 110 (Connection timed out)]
<EliasAmaral>
Thread 2 killed on uncaught exception Invalid_argument("Thread.kill: not implemented"), running as bytecode with linux, any workaround? seems undocumented
<EliasAmaral>
I can't compile to native code because it says "gcc: /usr/lib/ocaml/3.09.2/unix.o: Arquivo ou diretório inexistente" (file or directory doesn't exists)
<EliasAmaral>
when I compile with ocamlopt -I +threads -o p-life unix.cmx threads.cmxa event.cmx p-life.ml
<EliasAmaral>
Hmm, but which threads can be killed?
<EliasAmaral>
Win32 threads only?
* EliasAmaral
reading
<tsuyoshi>
that seems to indicate that posix threads on linux can be killed
<tsuyoshi>
I don't know... threads on unix have always seemed to have too many disadvantages to be worthwhile to me, versus processes
<tsuyoshi>
actually I shouldn't say that, I used to be enthusiastic about threads
<EliasAmaral>
but Thread.create creates "Lightweight threads for Posix 1003.1c and Win32.", as the reference says
<tsuyoshi>
but now I think they're too much trouble.. you run into all sorts of problems like this
<tsuyoshi>
EliasAmaral: what kind of system are you on?
<EliasAmaral>
tsuyoshi, i am relying on _one_ "global" variable being shared to the whole body of threads, and i am willing do use mutexes to control it
<EliasAmaral>
well, it's a group of parallels simulations
<EliasAmaral>
each one can kill a simulation (including itself), create a simulation, etc
<EliasAmaral>
they share a hash table that stores all simulations
<EliasAmaral>
tsuyoshi, i will just store a bool ref that is visible by both the killer and the killed thread
<EliasAmaral>
do you think that this is a good solution?
<EliasAmaral>
I could use Event.send, but this seems an overkill
<tsuyoshi>
what does the bool store?
<EliasAmaral>
"should the target thread stop itself?"
seafoodX has quit []
<tsuyoshi>
oh
<tsuyoshi>
that seems to be the recommended way to do it
<EliasAmaral>
it could be "too imperative"
flux-_ has joined #ocaml
flux has quit [Read error: 110 (Connection timed out)]
[azoic] has quit ["Leaving."]
seafoodX has joined #ocaml
flux-_ is now known as flux
<tsuyoshi>
hmm well stopping a thread is imperative no matter how you do it
Mr_Awesome has quit ["aunt jemima is the devil!"]
Mr_Awesome has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Connection timed out]
ramki has joined #ocaml
<flux>
eliasamaral, this piece of program exits immediately: let _ = Thread.create (fun () -> Unix.sleep 10) ()
<flux>
eliasamaral, so it leads me to believe that infact remaining threads are not waited
<EliasAmaral>
i didn't knew that there would be a "main" thread
<EliasAmaral>
in my head, once created another thread in the program, i have two threads with equal rights
<EliasAmaral>
btw, if anyone wants to see what i was doing, http://189.12.150.145/~dark/e/p-life/p-life.ml , it's an "hello world" that creates two simulations of conway's game of life that has some events that generates the output
<EliasAmaral>
and, Thread.kill in the end proved itself unecessary, but just because I already kept track of which threads are "valid" elsewhere, but I considered it nice :(
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
jonathanv has quit [Read error: 104 (Connection reset by peer)]
jlouis_ has quit [Connection timed out]
<flux>
I would never consider Thread.kill nice
<flux>
btw, threads in ocaml don't give you concurrency
<flux>
but I think with cothreads you will receive thread-like concurrency with processes..
kelaouch1 has quit [Client Quit]
kelaouchi has joined #ocaml
Demitar has joined #ocaml
<EliasAmaral>
flux, hmm, but with cothreads i can share data between threads?
<EliasAmaral>
if not i am considering using just fork() and having some message passing mechanism
<EliasAmaral>
but, well, i am going to sleep now =) bye bye
replore has joined #ocaml
olegfink has quit [Read error: 104 (Connection reset by peer)]
replore has quit [Read error: 113 (No route to host)]
olegfink has joined #ocaml
seafoodX has quit []
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
pantsd has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
iratsu has joined #ocaml
Tetsuo has joined #ocaml
<hcarty>
EliasAmaral: I think that is what cothreads is meant to provide, along with the ability to switch implementations without changing the source code