<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Arial;color: #000000;font-size: 10pt;">Hi Roberto,<br>
<br>
AFAIK for the user global locks work similar to other mutex/lock implementation, in your case
<font face="monospace, monospace">{?MODULE, lock_mnesia_for_a_while} is your 'mutex'. Locking this mutex does not automagically lock mnesia or guard shared data structures. However, a second process trying to aquire/lock the mutex will be blocked until the
 current owner releases the lock.<br>
<br>
Please correct me if I'm wrong.<br>
<br>
Regards<br>
Tobias<br>
</font>
<div><br>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF922847"><font color="#000000" face="Tahoma" size="2"><b>Von:</b> erlang-questions-bounces@erlang.org [erlang-questions-bounces@erlang.org]" im Auftrag von "Roberto Ostinelli [roberto@widetag.com]<br>
<b>Gesendet:</b> Donnerstag, 10. Dezember 2015 12:16<br>
<b>An:</b> Erlang<br>
<b>Betreff:</b> [erlang-questions] Understanding global:set_lock/1,2,3<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">Dear list,
<div>I'm trying to get an understanding of what global:set_lock/1,2,3 exactly does.</div>
<div><br>
</div>
<div>I read from the docs:</div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px"><font face="monospace, monospace">Sets a lock on the specified nodes (or on all nodes if none are specified) on ResourceId for LockRequesterId.</font></blockquote>
<div><br>
</div>
<div>Let's say that I want to perform a series of operations on mnesia schemas and want to avoid all other nodes accessing mnesia tables while one node is busy at it.</div>
<div><br>
</div>
<div>Is it enough to write:</div>
<div><br>
</div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div><font face="monospace, monospace">global:trans({{?MODULE, lock_mnesia_for_a_while}, self()},</font></div>
<div><font face="monospace, monospace">    fun() -></font></div>
<div><font face="monospace, monospace">        do_things_on_mnesia()</font></div>
<div><font face="monospace, monospace">    end).</font></div>
</blockquote>
<div><br>
</div>
<div>I don't get how this could lock mnesia for the other nodes.</div>
<div><br>
</div>
<div>Can some kind soul point me in the right direction?</div>
<div><br>
</div>
<div>Thank you,</div>
<div>r.</div>
</div>
</div>
</div>
</div>
</body>
</html>