<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">My consern with a read lock is that multiple Gems can obtain a read lock on the same object. You should consider a write lock instead.<div><br></div><div>James<br><div><br><blockquote type="cite"><div>On Jun 2, 2023, at 12:17 PM, Otto Behrens <otto@finworks.biz> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">Thanks everyone. I opted for a read lock as a mutex. I release the lock in an ensure block. This appears to be the simplest as I cannot rely on transactions at the point in time when this is invoked. Let's see what happens.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td width="400" valign="bottom"><div style="margin: 0px; padding: 0px;"><span style="font-size:18px;color:rgb(146,148,151);font-family:Calibri,sans-serif;font-weight:700">Otto Behrens</span><br></div><div style="font-size: 18px; font-weight: 700; color: rgb(146, 148, 151); font-family: Calibri, sans-serif; margin: 0px; padding: 0px;"><span style="font-size:14px;font-weight:300;margin:0px;padding:0px">+27 82 809 2375</span></div></td><td width="200" valign="middle"><img src="https://www.finworks.biz/signature/finworks-signature-logo.png" width="200" height="38" alt="FINWorks" style="display:block;border:0px;width:200px;height:38px;margin:0px;padding:0px"></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td height="5"></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(200, 28, 36);"><tbody><tr><td height="15"></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td height="20"></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td width="15" valign="top" style="display:inline-block"><a href="http://za.linkedin.com/in/waltherbehrens" style="color:rgb(17,85,204)" target="_blank"><img src="https://www.finworks.biz/signature/finworks-linkedin-logo.png" width="15" height="15" alt="FINWorks" style="display:inline-block;border:0px;width:15px;height:15px;margin-top:1.5px;padding:0px"></a></td><td width="250" valign="top" style="display:inline-block"><a href="http://www.finworks.biz/" style="color:rgb(200,28,36);font-family:Calibri,sans-serif;margin-left:10px;margin-top:0px;padding-top:0px;font-size:11pt;display:inline-block" target="_blank">www.finworks.biz</a></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td height="10"></td></tr></tbody></table><table width="600" cellpadding="0" cellspacing="0" border="0" style="font-family: Times; font-size: medium;"><tbody><tr><td><p style="font-size:10px;color:rgb(146,148,151);font-family:Calibri,sans-serif;text-align:justify">Disclaimer & Confidentiality Note: This email is intended solely for the use of the individual or entity named above as it may contain information that is confidential and privileged. If you are not the intended recipient, be advised that any dissemination, distribution or copying of this email is strictly prohibited. FINWorks cannot be held liable by any person other than the addressee in respect of any opinions, conclusions, advice or other information contained in this email.</p></td></tr></tbody></table></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 2, 2023 at 6:04 PM Norm Green via Glass <<a href="mailto:glass@lists.gemtalksystems.com">glass@lists.gemtalksystems.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
Hi Otto,<br>
<br>
There is file locking protocol in GsFile under category #locking.
There are several caveats and restrictions so be sure to read the
methods carefully. Also note that file locking over NFS is buggy and
should not be relied upon. If your zip files are on NFS you could
create a local (not on NFS) 1 byte file with a known name in a known
location and lock it when the zip file is in use.<br>
<br>
There are other ways to do this as well as James says. For example,
you could also use a shared counter (in class System) as your lock
bit and use a KeyValueDictionary to map the file name to the shared
counter ID.<br>
<br>
Norm Green<br>
<br>
<div>On 6/2/2023 5:09 AM, Otto Behrens via
Glass wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi,
<div><br>
</div>
<div>We have zipped files (references stored in GemStone with
MAExternalFileModel) that we use in an operation, for example
to merge PDF data (with PDFTk) or serve to the user via the
web server, while it is temporarily unzipped. The code is
something like this:</div>
<div><br>
</div>
<div>operation: aBlock</div>
<div> tempFile := f unzip.</div>
<div> ^ [ aBlock value: tempFile ] ensure: [ tempFile remove ]</div>
<div><br>
</div>
<div>We have on occasion multiple sessions that do operations on
the same file, which causes a problem. We would like to
protect the operation with a semaphore or something like that.</div>
<div><br>
</div>
<div>Is a Semaphore the way to solve this or is there a better
alternative?</div>
<div><br>
</div>
<div>If we use Semaphore and store it on our file object, we
cannot commit because we cannot persist the semaphore instVar.
According to the programming guide, "if you need to
encapsulate objects that should not be persistent, such as
semaphores, within object structures that do need to be
persistent and shared".</div>
<div><br>
</div>
<div>I am unsure how to structure this or if this is a
good idea. Can anyone please help?</div>
<div><br>
</div>
<div>Kind regards</div>
<div>
<div>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="400" valign="bottom"><div style="margin: 0px; padding: 0px;"><span style="font-size:18px;color:rgb(146,148,151);font-family:Calibri,sans-serif;font-weight:700">Otto
Behrens</span><br>
</div><div style="font-size: 18px; font-weight: 700; color: rgb(146, 148, 151); font-family: Calibri, sans-serif; margin: 0px; padding: 0px;"><span style="font-size:14px;font-weight:300;margin:0px;padding:0px">+27 82 809
2375</span></div>
</td>
<td width="200" valign="middle"><img src="https://www.finworks.biz/signature/finworks-signature-logo.png" alt="FINWorks" style="display: block; border: 0px; width: 200px; height: 38px; margin: 0px; padding: 0px;" width="200" height="38"></td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td height="5"><br>
</td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(200, 28, 36);" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td height="15"><br>
</td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td height="20"><br>
</td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="display:inline-block" width="15" valign="top"><a href="http://za.linkedin.com/in/waltherbehrens" style="color:rgb(17,85,204)" target="_blank"><img src="https://www.finworks.biz/signature/finworks-linkedin-logo.png" alt="FINWorks" style="display: inline-block; border: 0px; width: 15px; height: 15px; margin-top: 1.5px; padding: 0px;" width="15" height="15"></a></td>
<td style="display:inline-block" width="250" valign="top"><a href="http://www.finworks.biz/" style="color:rgb(200,28,36);font-family:Calibri,sans-serif;margin-left:10px;margin-top:0px;padding-top:0px;font-size:11pt;display:inline-block" target="_blank">www.finworks.biz</a></td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td height="10"><br>
</td>
</tr>
</tbody>
</table>
<table style="font-family: Times; font-size: medium;" width="600" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td><p style="font-size:10px;color:rgb(146,148,151);font-family:Calibri,sans-serif;text-align:justify">Disclaimer
& Confidentiality Note: This email is
intended solely for the use of the
individual or entity named above as it may
contain information that is confidential
and privileged. If you are not the
intended recipient, be advised that any
dissemination, distribution or copying of
this email is strictly prohibited.
FINWorks cannot be held liable by any
person other than the addressee in respect
of any opinions, conclusions, advice or
other information contained in this email.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Glass mailing list
<a href="mailto:Glass@lists.gemtalksystems.com" target="_blank">Glass@lists.gemtalksystems.com</a>
<a href="https://lists.gemtalksystems.com/mailman/listinfo/glass" target="_blank">https://lists.gemtalksystems.com/mailman/listinfo/glass</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>
Glass mailing list<br>
<a href="mailto:Glass@lists.gemtalksystems.com" target="_blank">Glass@lists.gemtalksystems.com</a><br>
<a href="https://lists.gemtalksystems.com/mailman/listinfo/glass" rel="noreferrer" target="_blank">https://lists.gemtalksystems.com/mailman/listinfo/glass</a><br>
</blockquote></div>
</div></blockquote></div><br></div></body></html>