adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.07.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.07/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml | Due to ongoing spam, you must register your nickname to talk on the channel
<oni-on-ion> humpy
<oni-on-ion> sorry wrong chan. numpy is not related here is it =)
<oni-on-ion> i liked the name as "Objective Caml/CAML" fwiw
<_y> a question for thread experts ! http://paste.awesom.eu/sjY5&ln
<_y> here, i am trying to make a producer thread P which would “yield” values that a consumer thread C would receive (in this example, the values are the integers from 1 to 100)
<_y> so i use a shared memory cell, and i need some kind of synchronization
<_y> but the output is not what i expected, and since i fail to find an error in my small concurrent algorithm, i am starting to suspect that some functions from Mutex or from Condition do not behave as i think
<_y> (more precisely, i want P to wait for C to be ready, before producing a new value; but in the example output, P produces several values (each one overwriting the previous one) before C can read one)
<_y> my hypothesis right now is that `Condition.signal` (in thread P) returns before `Condition.wait` (in thread C) has re-acquired the mutex
<_y> so that thread P may run faster than C and acquire the mutex before C does, in which case C would fail acquiring the mutex and wait again
<_y> is this to be expected ? any advice how to fix it ?
KeyJoo has quit [Ping timeout: 252 seconds]
normz has joined #ocaml
normz has quit [K-Lined]
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
keep_learning has quit [Remote host closed the connection]
mfp has quit [Ping timeout: 252 seconds]
mcc has joined #ocaml
silver_ has quit [Read error: Connection reset by peer]
<Fare> How do you write code so you can stub out some modules for testing? You build everything as parameterized modules, then have the top module instantiate the entire world statically or dynamically using first-class module?
tormen has joined #ocaml
rickymiller24 has joined #ocaml
tormen_ has quit [Ping timeout: 245 seconds]
rickymiller24 has quit [Ping timeout: 252 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
jao has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
kvda has joined #ocaml
_whitelogger has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 245 seconds]
Fare has quit [Ping timeout: 252 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
Fare has joined #ocaml
FreeBirdLjj has joined #ocaml
TC01 has quit [Ping timeout: 240 seconds]
TC01 has joined #ocaml
Fare has quit [Ping timeout: 252 seconds]
JimmyRcom has quit [Ping timeout: 244 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
Fare has joined #ocaml
Fare has quit [Ping timeout: 252 seconds]
kleimkuhler has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
zv has quit [Ping timeout: 240 seconds]
zv has joined #ocaml
jbrown has quit [Ping timeout: 246 seconds]
Dago_23 has joined #ocaml
bartholin has joined #ocaml
Dago_23 has quit [Ping timeout: 252 seconds]
kakadu has joined #ocaml
_whitelogger has joined #ocaml
peters-tx12 has joined #ocaml
peters-tx12 has quit [Ping timeout: 252 seconds]
kleimkuhler has quit [Quit: kleimkuhler]
FreeBirdLjj has joined #ocaml
annmygdala1 has joined #ocaml
Mayoi has joined #ocaml
TheLemonMan has joined #ocaml
Mayoi has quit [Remote host closed the connection]
erkin has quit [Ping timeout: 245 seconds]
erkin has joined #ocaml
erkin has quit [Remote host closed the connection]
erkin has joined #ocaml
annmygdala1 has quit [Ping timeout: 244 seconds]
RDUB0 has joined #ocaml
kvda has joined #ocaml
kleimkuhler has joined #ocaml
RDUB0 has quit [Ping timeout: 252 seconds]
kleimkuhler has quit [Quit: kleimkuhler]
<madroach> _y: I think the producer should signal the consumer and the consumer should wait for the producer.
mcc has quit [Quit: Connection closed for inactivity]
kleimkuhler has joined #ocaml
kleimkuhler has quit [Quit: kleimkuhler]
erkin has quit [Ping timeout: 252 seconds]
erkin has joined #ocaml
<flux[m]> _y: your code is slightly messed up
<flux[m]> the consumer should hold the mutex
<flux[m]> waiting a signal then releases the mutex and atomically re-acquires it again when returning
<flux[m]> ah, there's actually a Mutex.lock in the beginning, never mind :)
ggole has joined #ocaml
<flux[m]> but you shouldn't really assume the thread waiting will wake immediately
<flux[m]> mutexes/conditions aren't a "countable" synchronization mechanism, but your code assumes the Condition.wait will return exactly as many times as you call Condition.signal
<flux[m]> instead you should ie. use Queue as the signaling mechanism and the signal you want to send is "the is data in Queue". the consumer thread then (while holding the lock) will handle all the data from the Queue
<flux[m]> ..and then the predicate "there is data in queue" no longer holds, and it gets to wait for more data
<flux[m]> btw, for a more directly applicable synchronization primitive you could look into semaphores. I don't think OCaml comes with them, though.
zv has quit [Ping timeout: 240 seconds]
ggole has quit [Quit: ggole]
ggole has joined #ocaml
zv has joined #ocaml
ggole has quit [Client Quit]
ggole has joined #ocaml
ggole has quit [Client Quit]
ggole has joined #ocaml
jerichowasahoax6 has joined #ocaml
jerichowasahoax6 has quit [Remote host closed the connection]
jnavila has joined #ocaml
mfp has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kalio has quit [Ping timeout: 260 seconds]
jnavila has quit [Ping timeout: 240 seconds]
saiyan12 has joined #ocaml
saiyan12 has quit [Remote host closed the connection]
jnavila has joined #ocaml
moei has quit [Ping timeout: 252 seconds]
benzrf15 has joined #ocaml
kvda has joined #ocaml
benzrf15 has quit [Remote host closed the connection]
Haudegen has joined #ocaml
Welcome has joined #ocaml
Welcome has quit [Remote host closed the connection]
neatonk has joined #ocaml
_whitelogger has joined #ocaml
tyteen4a039 has joined #ocaml
moei has joined #ocaml
tyteen4a039 has quit [Remote host closed the connection]
tg has quit [Ping timeout: 246 seconds]
picolino has quit [Remote host closed the connection]
picolino has joined #ocaml
zv has quit [Ping timeout: 240 seconds]
tg has joined #ocaml
kokx`13 has joined #ocaml
orbifx has joined #ocaml
zv has joined #ocaml
kokx`13 has quit [Remote host closed the connection]
silver has joined #ocaml
pioneer42 has joined #ocaml
kalio has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
pioneer42 has quit [Quit: Leaving.]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbifx has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
jmcgnh21 has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
jmcgnh21 has quit [Ping timeout: 272 seconds]
rewt13 has joined #ocaml
rewt13 has quit [Remote host closed the connection]
sobkas5 has joined #ocaml
sobkas5 has quit [Remote host closed the connection]
picolino has quit [Read error: No route to host]
orbifx1 has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
picolino has joined #ocaml
<orbifx1> is there a pgp library?
<hannes> orbifx1: https://github.com/cfcs/ocaml-openpgp is wip afaict
<companion_cube> any idea where `opam travis` is supposed to come from?
<companion_cube> I'd like to check scripts locally, not sure if it's possible
picolino has quit [Ping timeout: 252 seconds]
<tizoc> "[ERROR] The sources of the following couldn't be obtained, aborting:" (and a list of cohttp packages next)
<tizoc> has anyone seen this error since upgrading to opam2 ?
<tizoc> ok, I think i found the issue after enabling verbose mode
<tizoc> + /usr/bin/openssl "sha512" "/Users/bruno/.opam/default/.opam-switch/sources/cohttp-lwt-unix.1.1.1/v1.1.1.tar.gz"
<tizoc> - openssl:Error: 'sha512' is an invalid command.
kleimkuhler has joined #ocaml
kleimkuhler has quit [Client Quit]
pierpal has quit [Ping timeout: 246 seconds]
kleimkuhler has joined #ocaml
KeyJoo has joined #ocaml
ziyourenxiang has quit [Ping timeout: 260 seconds]
kleimkuhler has quit [Quit: kleimkuhler]
Haudegen has quit [Remote host closed the connection]
kleimkuhler has joined #ocaml
polydin has joined #ocaml
neatonk has quit [Remote host closed the connection]
polydin has quit [Killed (Sigyn (Spam is off topic on freenode.))]
neatonk has joined #ocaml
pierpal has joined #ocaml
<tizoc> whats the best way to handle hygiene in ppx rewriters? (I see ppx_deriving has a helper for this, but my rewriter is not a deriving one)
<tizoc> (basic example, I generate code that uses List.map, and I want to make sure that the generated code references stdlib's List module and not something else in the scope)
kleimkuhler has quit [Quit: kleimkuhler]
<ZirconiumX> Write your own List.map?
<ZirconiumX> I think that's the only way to ensure it, really
Fare has joined #ocaml
<companion_cube> or Stdlib.List.map? if someone overloads that it's really their own fault?
<ZirconiumX> Something something Jane Street
<companion_cube> I don't think they will modify `Stdlib`
<companion_cube> I sure hope they don't, rather*
<orbifx1> thanks hannes
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
<tizoc> companion_cube: yes, thats what I ended doing
FreeBirdLjj has quit [Ping timeout: 246 seconds]
Fare has quit [Ping timeout: 272 seconds]
oni-on-ion has quit [Quit: WeeChat 1.9.1]
aydio has joined #ocaml
Jesin has quit [Quit: Leaving]
Guest59959 has joined #ocaml
troydm has quit [Ping timeout: 240 seconds]
Guest59959 has quit [Ping timeout: 252 seconds]
<tizoc> all this ppxlib replacing ppx_driver stuff has me confused
ftlight has quit [Quit: ヾ(´¬`)ノ]
ftlight has joined #ocaml
jim7j1ajh has joined #ocaml
jimt has quit [Ping timeout: 252 seconds]
oni-on-ion has joined #ocaml
rcvu23 has joined #ocaml
rcvu23 has quit [Ping timeout: 246 seconds]
troydm has joined #ocaml
sdh_28 has joined #ocaml
sdh_28 has quit [Remote host closed the connection]
Jesin has joined #ocaml
KeyJoo has quit [Ping timeout: 252 seconds]
discord has quit [Remote host closed the connection]
discord has joined #ocaml
pmetzger has joined #ocaml
<pmetzger> test
pmetzger has quit [Client Quit]
noitakomentaja has joined #ocaml
ggole has quit [Quit: ggole]
kleimkuhler has joined #ocaml
nokomprendo has joined #ocaml
pierpal has quit [Ping timeout: 244 seconds]
Jesin has quit [Quit: Leaving]
Fare has joined #ocaml
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 244 seconds]
Jesin has joined #ocaml
jnavila has quit [Remote host closed the connection]
pierpal has joined #ocaml
orbifx1 has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
kleimkuhler has quit [Quit: kleimkuhler]
kleimkuhler has joined #ocaml
kleimkuhler has quit [Client Quit]
Haugli921 has joined #ocaml
ketralni` has joined #ocaml
Haugli921 has quit [Remote host closed the connection]
infinity0 has quit [Remote host closed the connection]
Xinayder has joined #ocaml
infinity0 has joined #ocaml
ketralni` has quit [Remote host closed the connection]
Xinayder has quit [Remote host closed the connection]
Fare has quit [Ping timeout: 252 seconds]
kakadu has quit [Remote host closed the connection]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<Leonidas> tizoc: while we can't depend on the Stdlib module yet, we use a runtime module compiled against the stdlib and reference everything from there.
<Leonidas> ZirconiumX: fun fact: Jane Street had `Stdlib` longer than OCaml itself, it is called `Caml` there.
<Leonidas> And is available in older OCaml versions too
bartholin has quit [Remote host closed the connection]
<tizoc> Leonidas: interesting, thank you
<ZirconiumX> Leonidas: yeah, I know
<_y> flux[m], ok, thanks for your insight
<ZirconiumX> But if you're referencing Stdlib.List.map, then it won't work using Core
FireFighter has joined #ocaml
<Leonidas> Why wouldn't it? I don't think Core messes with Stdlib.
<_y> in my case i specifically want to avoid accumulating un unbounded number of values, because there can be a huge number of them, or even an infinite number
<_y> so no Queue
FireFighter has quit [Remote host closed the connection]
<_y> in fact it seems that i can easily do exactly what i want with the Event module https://caml.inria.fr/pub/docs/manual-ocaml/libref/Event.html
<_y> i am trying to avoid it because while browsing the source code, i saw that it was overly complicated for my use case, so that it would imply un unnecessary overhead
<_y> for the record, the simplest solution i could come up with implies adding a mutex and a wait/signal pair http://paste.awesom.eu/rWuN&ln
orbifx1 has quit [Ping timeout: 240 seconds]
orbifx1 has joined #ocaml
orbifx1 has quit [Ping timeout: 252 seconds]
glass has joined #ocaml
theglass has quit [Ping timeout: 260 seconds]
<_y> flux[m], thanks for suggesting semaphores; i believe that the module Condition actually implements semaphores https://caml.inria.fr/pub/docs/manual-ocaml/libref/Condition.html (at least this is what https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora176.html#toc261 implies)
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
Fardale has quit [Ping timeout: 240 seconds]
<_y> well, semaphores with an added feature about mutexes
aydio has quit [Quit: WeeChat 2.2]
<flux[m]> _y: no, Condition doesn't implement semaphored
<flux[m]> Mutex is like a special case of semaphores, though
<companion_cube> _y: may I interest you in containers.thread ? :p
<_y> what is the difference between Conditions and semaphores, then ?
Fardale has joined #ocaml
<_y> companion_cube, you may try
<_y> CCBlockingQueue looks very related indeed, thanks :-)
<companion_cube> before serious use, consider testing it further, please :)
<companion_cube> this kind of stuff is really tricky to get right
<_y> yeah
<companion_cube> there are tests but I'd love to have more
<companion_cube> regarding conditions: they're just used to wait for someone to notify (or notify all), they must be paired with a mutex
ziyourenxiang has joined #ocaml
<_y> i tried using threads from utop, and had trouble
<_y> (1) is it normal that “utop -I +threads unix.cma threads.cma” does not work (it does not find threads.cma) whereas “ocaml” with the same options does work ?
<companion_cube> hmmm I'm never sure about threads in topleve
<companion_cube> #require "threads";; may work?
<_y> (2) after problem (1) has been solved (by giving an explicit path, as in “-I ~/.opam/daily/lib/ocaml/threads”), utop fails with the message “Fatal error: exception Unix.Unix_error(Unix.ENOENT, "open", "/home/me/.lambda-term-inputrc")”
<_y> which really looks like a bug and not an actual error message; moreover it seems weird that using threads would require ~/.lambda-term-inputrc to exist
<_y> (the problem is circumvented by “~/.lambda-term-inputrc”)
<_y> (the problem is circumvented by “touch ~/.lambda-term-inputrc”)
<_y> companion_cube, it doesn’t seem so
<companion_cube> hmmmmm