companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 272 seconds]
gebn has quit [Ping timeout: 276 seconds]
Tuplanolla has quit [Quit: Leaving.]
gebn has joined #ocaml
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
<za3k> am i allowed to use a Mutex across domains? if not, what can I use instead?
<za3k> i basically just want to delay starting the client until the server is ready, nothing fancy needed
<discocaml> <contificate> you can use mutexes across domains
<discocaml> <contificate> in fact, the example from the manual does exactly that: https://ocaml.org/manual/5.1/parallelism.html
<discocaml> <contificate> if it helps, you can just imagine that OCaml 4 uses a global runtime lock that ensures pthreads don't run in parallel - with domains, this lock becomes per domain, so many pthreads can be scheduled in parallel - the underlying pthread_mutex_t is still intact for mutexes
<discocaml> <contificate> same way you'd use pthreads in C and expect actual parallelism on multiple cores
<za3k> hmm okay, maybe i misdiagnosed the problem them
Haudegen has quit [Quit: Bin weg.]
<za3k> The actual error I am seeing is: Fatal error: exception Sys_error("Mutex.lock: Resource deadlock avoided")
<discocaml> <contificate> probably the simple case of trying to use a pthread as a recursive mutex
<discocaml> <contificate> the runtime detects this
<discocaml> <contificate> OCaml provides no builtin recursive mutex, despite the fact that pthreads does
<discocaml> <contificate> but easy to implement with an atomic counter or something
<za3k> What is a recursive mutex?
<za3k> Locking twice from the same thread, maybe?
<discocaml> <contificate> yeah
<discocaml> <contificate> you can acquire multiple "holds"
<za3k> that's actually what I want to do though, is wait until another thread unlocks it
<za3k> i basically just want to start thread B, and then wait for a signal from thread B, and then continue
<za3k> but the library docs on condition variables made it sound like there were lots of spurious wakeups
<discocaml> <contificate> spurious wakeups are fine
<discocaml> <contificate> you just do the waiting in a loop that begins waiting again if the condition is false
<discocaml> <contificate> a kind of small annoyance with threads is the setup requires synchronisation as well
<za3k> i mean there's no actual condition though--i just want to wait for a signal
<za3k> i have no idea how to set up some kind of shared flag, if i wanted to artifically add something
<discocaml> <contificate> you can signal between threads using Atomic.t
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
<discocaml> <darrenldl> you can do counting semaphores
<discocaml> <darrenldl> but condition variable is probably better
<za3k> i did a condition variable checking an atomic, which is overkill but eh it works now
<za3k> it turns out my problem was that the domain was crashing with an exception, and I guess nothing prints in that case?
<za3k> i'll have to educate myself properly
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
pi3ce has quit [Ping timeout: 252 seconds]
<discocaml> <darrenldl> i think the usual pattern is to pair condition var with mutex + bool ref, but i dont actually remember the reasoning and thus not sure if atomic suffices
pi3ce has joined #ocaml
alfiee has joined #ocaml
<companion_cube> a bool atomic is fine but it won't provide a "wait for condition" part
<companion_cube> more like a "poll for condition"
alfiee has quit [Ping timeout: 248 seconds]
<discocaml> <lhommemagique> hello everyone, I was wondering if Ocaml was used for Network Automation at all. I know python is the default language, but I was wondering if there were any libraries or tools that used Ocaml.
<discocaml> <contificate> ccube: in the case of spurious wakeup with condition vars, you need a flag to check that can only be set - I default to atomics over `ref`, I was not suggesting spinlocking
<discocaml> <contificate> only be set in a threadsafe way*
<companion_cube> oh sure, if you have a mutex and condition variable they'll dominate the cost anyway
wbooze has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
deadmarshal_ has quit [Ping timeout: 268 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
deadmarshal_ has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 248 seconds]
casastorta has quit [Quit: ZNC 1.9.1 - https://znc.in]
casastorta has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 248 seconds]
deadmarshal_ has quit [Remote host closed the connection]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
salkin has quit [Ping timeout: 272 seconds]
keyboard has quit [Ping timeout: 272 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
deadmarshal_ has joined #ocaml
bartholin has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 245 seconds]
wickedshell has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
bartholin has quit [Quit: Leaving]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 272 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
wickedshell has joined #ocaml
alfiee has joined #ocaml
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
alfiee has quit [Ping timeout: 260 seconds]
bibi_ has quit [Remote host closed the connection]
bibi_ has joined #ocaml
<wbooze> why do i get Unix.timegm and Unix.strptime mentions in ocaml .ml source files i have no idea, as the Unix manual tells there's no such things....
<wbooze> bah
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
wbooze_ has joined #ocaml
wbooze is now known as Guest5774
Guest5774 has quit [Killed (silver.libera.chat (Nickname regained by services))]
wbooze_ is now known as wbooze
<discocaml> <contificate> Probably Jane Street's Core_unix
<discocaml> <contificate> which provides both of them, not OCaml's stdlib Unix
<wbooze> oh
<wbooze> any way to get that installed ?
mange has quit [Quit: Zzz...]
<wbooze> seems not, neither core_unix.cma nor unix.cma change anything
<wbooze> well, ok i think i have to give up that one .ml file at least...
JuanDaugherty has joined #ocaml
alfiee has joined #ocaml
<discocaml> <gooby_diatonic> Would it make sense to make something like Riot but based on Picos?
abbe__ has quit [Ping timeout: 252 seconds]
abbe__ has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
JuanDaugherty has quit [Quit: praxis.meansofproduction.biz (juan@acm.org)]
rgrinberg has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
rgrinberg has quit [Client Quit]
alfiee has joined #ocaml
wbooze has quit [Ping timeout: 260 seconds]
alfiee has quit [Ping timeout: 245 seconds]
eilvelia has quit [Read error: Connection reset by peer]
eilvelia_ has joined #ocaml
eilvelia_ is now known as eilvelia
alfiee has joined #ocaml
semarie has quit [Read error: Connection reset by peer]
semarie has joined #ocaml
alfiee has quit [Ping timeout: 268 seconds]
Haudegen has joined #ocaml
wbooze has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
Tuplanolla has joined #ocaml
alfiee has joined #ocaml
keyboard has joined #ocaml
alfiee has quit [Ping timeout: 248 seconds]
wickedshell has quit [Remote host closed the connection]
euphores has quit [Quit: Leaving.]
euphores has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
Haudegen has quit [Quit: Bin weg.]
<discocaml> <yawaramin> maybe. the main obstacle is time and effort. concurreny runtimes are huge and complex beasts
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
wbooze has quit [Ping timeout: 244 seconds]
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
<discocaml> <gooby_diatonic> I was wondering more about whether there'd be any benefit to doing so, if I understood Picos its goal is to make it easier to integrate different effectful libraries, but Riot has a very specific use case which seems self-contained
Haudegen has joined #ocaml
terrorjack has joined #ocaml
wbooze has joined #ocaml
Anarchos has joined #ocaml
alfiee has joined #ocaml
bartholin has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
wbooze has quit [Ping timeout: 265 seconds]
rgrinberg has joined #ocaml
<za3k> I'm trying to work out some code that will spawn a new domain, and then if that domain throws an exception, print it and immediately exit the main program
<za3k> I could use some help on this one
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<za3k> https://pastebin.com/nK89CPrA here is my attempt
<za3k> it exits after 1 second, but doesn't print anything
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
wickedshell has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
bartholin has quit [Quit: Leaving]
<discocaml> <contificate> You could join the domain and it will re-raise the exception within `join` if you don't handle it
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
JuanDaugherty has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]