[REBOL] How does one persist data? Re:
From: kracik:mbox:dkm:cz at: 11-Oct-2000 22:56
Hi Sharriff,
be careful when saving to a file and reading it later, as many users
may run your CGI programs simultaneously. You should use some form of
inter-process synchronization to serialize access to your file. AFAIK
from REBOL you can reliably synchronize by opening TCP sockets or
renaming a file. I use these two functions:
obtain-semaphore: func [] [
loop 100 [
if not error? try [ rename %lockdir/lock %lock.locked ] [
return
]
wait ( random 5 ) / 10
]
print "Could not obtain semaphore"
quit
]
release-semaphore: func [] [
loop 100 [
if not error? try [ rename %lockdir/lock.locked %lock ] [
return
]
wait ( random 5 ) / 10
]
print "Could not release semaphore"
quit
]
--
Michal Kracik
[Sharriff--Aina--med-iq--de] wrote: