Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Looks good! The call to
You do need some means of handling
Raise an exception if Domain.join is attempted multiple times. Concurrent joins would be undefined otherwise. Store the mutex in a non-movable C allocation, because copying mutexes is undefined. Also wrap pthread_join with blocking section. Signed-off-by: Edwin Török <email@example.com>
Thanks, I have added a mutex protected flag to detect multiple joins and exit early by raising an exception. Since I'm now storing a mutex inside the custom block I added another allocation (and a finalizer), I'm worried that OCaml's GC could move the custom block with the mutex in it which wouldn't be well defined.
Not sure whether I should just use
You're right, you do need a means to prevent the mutex moving. The standard idiom here is to allocate the