for. (It also works in pre-cfmx versions of cf.)
If you want to avoid locking on every single hit (after the initialization
is done) then use a two-layer kind of test like this pseudo code:
if not IsDefined("server.initIsDone") {
<cflock type=exclusive ...>
if not IsDefined("server.initIsDone") {
...do init stuff ...
server.initIsDone = 1
}
</cflock>
}
The idea is that you can do IsDefined without locking, so (way) after init
is done all hits will skip this section of code, but the few hits that
manage to get in before init is done will be delayed trying to get the lock,
and once they get the lock they will notice that the shared variable has
been defined and won't actually init anything.
I use this style in lots of languages (cf, java, C#, etc).
Mark
-----Original Message-----
From: Brook Davies [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 2:35 PM
To: CF-Talk
Subject: Race conditions at start up
When my CFMX server is restarted my app needs to do a lot of housekeeping.
It goes out and fetches the exchange rate, it sets up some application vars
etc, etc.
This takes some time and I am finding that what is happening is if the
server is restarted under load, that the running requests grows quickly and
they are all trying to run these startup tasks. How can I make it so that
only one thread runs these startup tasks and the rest sit and wait
patiently for those tasks to finish?
Brook Davies
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

