Skip to main content
November 17, 2008
Question

How can I make this function thread safe?

  • November 17, 2008
  • 3 replies
  • 352 views
delete this post please. accidental.
    This topic has been closed for replies.

    3 replies

    Inspiring
    November 17, 2008
    i think you should still investigate using conditional loop in your
    function instead of having it call itself over and over with each
    iteration, passing more and more data around... it does not look like
    the best setup to me...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    November 17, 2008
    Thanks Azadi!!

    I took your advice and used a conditional loop instead of a recursive function - never thought about doing it that may!

    On the upside, it also sorted another problem out for me that I was having AND it gives about a 5-10% improvement on execution time. This is only with 3 nodes...with even more I bet that gap increases ever more.

    Thanks for helping me write tighter code!! (new function attached)

    Mikey.
    November 17, 2008
    It's okay thanks. I figured it out. All it required was a simple:

    <cfargument name="breadCrumbArray" hint="" required="no" type="array" default="#arrayNew(1)#" />

    <cfset var myArray = arguments.breadCrumbArray />

    All I needed to do was assign the argument to the var scope. Figured this out exactly when I post the message - typical!! Haha.

    Thanks.
    Mikey.
    Inspiring
    November 17, 2008
    is your function calling itself in its execution? that's why your array
    is being re-created with each call...
    sounds like you should be using a conditional loop... maybe something like:

    <cfset var functionItemID = arguments.itemID />
    <cfset var bcArray = arraynew(1)>

    <cfloop
    condition="application.tags.hasParent(functionItemID,arguments.itemDeleted,arguments.itemState)
    is true">
    <cfset
    arrayAppend(bcArray,application.tags.getItemField(functionItemID,"item_id"))
    />
    <cfset functionItemID =
    application.tags.getParent(functionItemID,arguments.itemDeleted,arguments.itemState)
    />
    </cfloop>

    <cfreturn bcArray />

    [NOTE: absolutely untested]

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/