On a slightly related note I've been implementing a system where the
navigation information for a site is stored in an application variable as an
xml document. Whenever I need to get a particular section of the site, I
call a function that read locks the application variable and does an xpath
search of the xml document for that particular section and it's children. So
here are my questions:

1) I use xmlSearch to return the section and it's child elements. Is the xml
node returned a reference into the original xml document that is held in the
application scope, or does xmlSearch actually duplicate all the nodes?

2) If this xml node is being manipulated in the CALLING function (after the
<cflock></cflock> code has already executed) is the xml element still
"protected" by the read lock? What would happen if the original XML document
was deleted or changed while I'm reading and processing one of it's child
elements (keeping in mind that the application variable is no longer locked
as I'm in a different function). If this is going to be a problem how do I
use and manipulate parts of a shared scope variable in a multiple calling
functions reliably?

3) This xml document is also streamed through flash remoting to flash based
admin tools to create a hierarchy of the site so that they can embed links
to various pages in the site. Presumably it might take quite a few seconds
for the xml to finish streaming from the application variable to the client.
What happens if the application variable is changed in the middle of this
process? Would this xml doc being streamed to the flash player not work
anymore? Is it even the same object that is being streamed to flash or was a
copy made and sent onward?

ed




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Jim Davis
Sent: Wednesday, January 19, 2005 11:00 PM
To: [email protected]
Subject: RE: [CFCDev] Objects byReference



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Barry L Beattie
> Sent: Wednesday, January 19, 2005 9:03 AM
> To: [email protected]
> Subject: Re: [CFCDev] Objects byReference
>
>
> >> If you have copied the struct into another variable (inside your
> objects) then the key will remain in the copies
>
> sure the key will remain as a local copy but that also means it's no
> longer pointing to the origional copy, yes?

I think you may considering things a little off.

There is no "real" copy of a by-reference thing (struct, query, component).
When you do this:

<cfset this.Foo = createObject() />

It creates the object "off in space" - in a special "instantiated object
closet".  "this.Foo" is given a reference to it, it doesn't contain the
"real" object.

Any and ALL references (originals and copies) to anything "by-reference" are
always references, not the objects themselves.

Now when you do:

<cfset this.Faa = this.Foo />

"this.Faa" gets another reference to the object (which is still happily
spending its two-minutes in the closet with all the other instantiated
objects).

Then when you do:

<cfset structDelete(this, "Foo") />

You're just deleting the reference to the object, not the object itself
(which is still in the closet linked by a reference to "this.Faa").

Finally if you do:

<cfset structDelete(this, "Faa") />

The last remaining reference to the object is deleted.  The object is still
in the closet but nothing can access it - there are no more references to
it.  So it's been "orphaned".

Periodically a system process called "Garbage Collection" sweeps through the
closet and deletes any objects with no references.  This is the only real
way to "destroy" an object.

I found this concept very daunting when structs were introduced way back
when...

Jim Davis



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to