<div dir="ltr">Hi Dmitry and Tobias,<br><div>Yes - it looks like these are simple mutex.</div><div><br></div><div>Thank you for your inputs!</div><div>r.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 10, 2015 at 1:55 PM, Tobias Schlager <span dir="ltr"><<a href="mailto:Tobias.Schlager@lindenbaum.eu" target="_blank">Tobias.Schlager@lindenbaum.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<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>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>Von:</b> <a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a> [<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a>]" im Auftrag von "Roberto Ostinelli [<a href="mailto:roberto@widetag.com" target="_blank">roberto@widetag.com</a>]<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 class="h5">
<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></div>
</div>
</div>

</blockquote></div><br></div>