<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I'm not sure you need this, but on shared filesystem (nfs e.g.), to implement generate-on-demand fashioned data production with parallelism, a trick is to create a temporary directory that exclusively named by your particular run of the critical section of the code. Expect failure from the os in creation of a generated name in location where your final file would go, to ensure same filesystem, and decorate it (with the value from a local counter e.g.) to not appear as the ultimately desired path/name - if failed, try another name; otherwise you succeeded, you are sure this dir is exclusive per your current execution thread, then generate the data (which would take time) and put the payload into a file inside this dir, then fsync to make sure the storage is permanent, then rename it to the ultimate file path/name you'd like it to be. Maybe another parallel process did the same thing and race to overwrite your production, that'll be fine as long as the file data generation algorithm holds some invariant, you'll never have a corrupted/incomplete file on the expected path/name this way.<div class=""><br class=""></div><div class="">I suggest this is never a Haskell thing but os tricks per se.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 2021-04-15, at 17:05, Sven Panne <<a href="mailto:svenpanne@gmail.com" class="">svenpanne@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Am Do., 15. Apr. 2021 um 10:24 Uhr schrieb Daniel Trstenjak <<a href="mailto:daniel.trstenjak@gmail.com" class="">daniel.trstenjak@gmail.com</a>>:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">And it's the safest, because a move is an atomic operation [...]</blockquote><div class=""><br class=""></div><div class="">... unless you are on Windows. ;-)</div></div></div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></body></html>