On 5/13/05, Kerry [EMAIL PROTECTED] wrote:
I was trying to make the point that because you are making a variable in app
scope, there will only ever be one, even without the lock.
But the object will be created more than once and that may be important.
application.myobj is still a singleton
.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Nando
Sent: 12 May 2005 21:11
To: CFCDev@cfczone.org
Subject: RE: SPAM-LOW: RE: [CFCDev] Singleton / Factory request
I'll contradict Peter here and say that yes you do need to lock that code
block as shown for the reason
: RE: [CFCDev] Singleton / Factory request
but, if you are creating the object in app scope, and x number of requests
cause the appstart code to run, then each subsequent request will overwrite
the last one, so there will still only be one instance of the object?
in saying that, I would do
-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Nando
Sent: 13 May 2005 10:53
To: CFCDev@cfczone.org
Subject: RE: SPAM-LOW: RE: [CFCDev] Singleton / Factory request
Kerry, i don't think there's much of any reason to create an object and
place it in application scope unless you make
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 13 May 2005 11:11
To: CFCDev@cfczone.org
Subject: RE: SPAM-LOW: RE: [CFCDev] Singleton / Factory request
I think maybe some mis-communication here.
i don't think there's much of any reason to create an object and
place it in application scope unless
cfif NOT
StructKeyExists(application,"mySingleton")cflock
name="mySingletonLock" Timeout="10"
THROWONTIMEOUT="No" Type="Exclusive"cfif NOT
StructKeyExists(application,"mySingleton")cfset
application.mySingleton =
CreateObject('component','Singleton').init()/cfif/cflock/cfif
Does
Thanks Nando,
I've ended up seperating the Singleton from the factory. Not sure if its the
best way though. Any comments appreciated.
Cheers, Pete (aka lad4bear)
In Application.cfc
!--- Instantiate ComponentManager ---
cfif not StructKeyExists(Application, 'ComponentFactoryManager')
cflock
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Peter H
Sent: 12 May 2005 16:39
To: CFCDev@cfczone.org
Subject: RE: [CFCDev] Singleton / Factory request
Thanks Nando,
I've ended up seperating the Singleton from the factory. Not sure if its the
best way though. Any
Kerry,
Thanks for that, it took a few minutes of staring blankly but I clicked what
you were saying in the end.
Cheers, Pete (aka lad4bear)
brbrbrOriginal Message FollowsbrFrom: quot;Kerryquot;
lt;[EMAIL PROTECTED]gt;brReply-To: CFCDev@cfczone.orgbrTo:
that it might be better to do it consistently ...
Something to think about at least.
:) n.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Peter H
Sent: Thursday, May 12, 2005 5:39 PM
To: CFCDev@cfczone.org
Subject: RE: [CFCDev] Singleton / Factory request
And you wanna know the funny thing? I just ran into that exact problem and
I've ended up doing precisely what you said. Would love to say great minds
think a like but I think I might be the tortoise in this race :)
On the subject of locking, I'm using cf6.1 - do I still need to lock?
Cheers
Application.cfm
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Peter J. Farrell
Sent: Thursday, May 12, 2005 9:42 PM
To: CFCDev@cfczone.org
Subject: Re: SPAM-LOW: RE: [CFCDev] Singleton / Factory request
Peter H wrote:
On the subject of locking, I'm using cf6.1 - do I
Nando wrote:
I'll contradict Peter here and say that yes you do need to lock that code
block as shown for the reason stated if you want to guarentee that one and
only one instance of that object can exist.
I assumed you were on MX7, because you referred to Application.cfc, but i
guess you meant
Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Nando
Sent: Thursday, May 12, 2005 4:11 PM
To: CFCDev@cfczone.org
Subject: RE: SPAM-LOW: RE: [CFCDev] Singleton / Factory request
I'll contradict Peter here and say that yes you do need to lock that code
block as shown
Hey! Get back in here!
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Peter J. Farrell
Sent: Thursday, May 12, 2005 11:09 PM
To: CFCDev@cfczone.org
Subject: SPAM-LOW: Re: [CFCDev] Singleton / Factory request
Nando wrote:
I'll contradict Peter here
15 matches
Mail list logo