On 6/22/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > While working with async gateways, I discovered some behaviour that I > thought'd I'd pass on to the group. Some of the more seasoned people may > already be aware of it but it threw me off for a while and I'd thought I > might save some people some headache by sharing. When calling async > gateways, its imperative that you pass a localized structure if you intend > on modifying the structure while the gateway process is running. Passing a > structure to the Event only passes a pointer to the structure.
Right, because structs are always passed by reference so in your first code example, all the processes operate on the same struct (you only create one new struct). Technically this could also be a problem if you executed the code serially, depending on what your routine did with the struct (e.g., if it used structKeyExists() to determine whether it had placed some result in there, subsequent function calls using that struct could be misled by the results of earlier function calls). Knowing that a single struct can be shared is useful since it allows asynchronous processes to communicate - that's how my Concurrency library works: it passes a shared object back and forth between the main page (in the FutureTask object) and the asynchronous thread (via FutureEvent). -- Sean A Corfield -- http://corfield.org/ Team Fusebox -- http://fusebox.org/ Got Gmail? -- I have 50, yes 50, invites to give away! "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
