Re: cfthread running condition?
Yeah, I've been wondering why this would use multiple threads when the aim is to deliberately single thread the execution. On Sat, Aug 30, 2008 at 12:44 PM, Mark Mandel wrote: Silly question - why not just run the executing code you want to fire to happen at the end of thread 1? It has exactly the same result, there is no need to create a whole new thread, as you can just continue in the one you are in. -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311829 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: cfthread running condition?
What! Are you saying the Emperor has no clothes! :o) Why point out the obvious and ruin a perfectly good, pointless discussion! It very well may be time to go back to just consolidate more and more code into one or at least few threads. I think I got started on the separate threads way back when I was first testing parts of the functionality in a browser and wanted feedback through the browser output about how the processing was working. Then I moved that code into separate templates that had to run in a specific order to process all the data. (54 templates at this point) I think I've just become obsessed with making threads bend to my will. It's definitely been a good learning experience about cfthread. I'll have to sit back and reconsider how best to use cfthread now that I'm consolidating many similar functions into single templates and running them as scheduled tasks still. I wish there was a way to watch scheduled tasks at work...showing data processing, outputting results, starting and finishing of tasks, etc. I generally just run the tasks in a browser when I need to see feedback. Or I send myself an email with results I need to see. Am I missing some sort of obvious feedback method when scheduled tasks (and cfthread's, for that matter) are run? Rick -Original Message- From: Mark Mandel [mailto:[EMAIL PROTECTED] Sent: Saturday, August 30, 2008 12:44 AM To: CF-Talk Subject: Re: cfthread running condition? Silly question - why not just run the executing code you want to fire to happen at the end of thread 1? It has exactly the same result, there is no need to create a whole new thread, as you can just continue in the one you are in. Mark On Sat, Aug 30, 2008 at 12:26 PM, Dave Watts [EMAIL PROTECTED] wrote: But unlike a page thread that's running in a browser, the scheduled task page thread isn't subject to a timeout, right? Why wouldn't it be? It's just another HTTP request. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311830 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: cfthread running condition?
This should be pretty simple to achieve. One of the restrictions with threads is that a cfthread can not spawn another cfthread. So your going to need one scheduled task that runs at a suitable interval. It will need to see if theres a thread running and if not, kick off the first thread. The threads will need to report there current status somewhere the scheduled task can check - to a db or application scope. When the scheduled task next runs it checks if the previous task completed and then starts the next thread. Chris Is there a way to make the start of one thread conditional upon the ending of a previous thread? I want to keep only one thread at a time running and would like to set up a series of threads to run, but only one at a time. I've been doing this with scheduled tasks and emailing completion to myself for verification of success each morning, but running 54 schedule task templates currently, with having to add another 30 or so soon has just become quite cumbersome. Didn't know if there were any options. Too bad we can't number the threads to run sequentially and set them to run only individually. Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311780 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfthread running condition?
You might be able to kick of the first thread (set the action to run) then have a list or something that you can loop over and have a join cfthread inside the loop with the same name as the first one. Something like this. cfthread action='run' name='t1' do something /cfthread cfloop index='i' from='1' to='50' cfthread action='join' name='t1' do something /cfthread /cfloop I have not tried this, but the 'join' action tells cf to wait for the named thread(t1) to finish. Joey Is there a way to make the start of one thread conditional upon the ending of a previous thread? I want to keep only one thread at a time running and would like to set up a series of threads to run, but only one at a time. I've been doing this with scheduled tasks and emailing completion to myself for verification of success each morning, but running 54 schedule task templates currently, with having to add another 30 or so soon has just become quite cumbersome. Didn't know if there were any options. Too bad we can't number the threads to run sequentially and set them to run only individually. Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311796 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: cfthread running condition?
Rick Faircloth wrote: Is there a way to make the start of one thread conditional upon the ending of a previous thread? It should be possible using the thread.status feature. You would create a thread then watch the status until it reports completed then start the next thread. Don't have a code example, but that is what I would imagine from my reading and experimenting with threads a while back. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311798 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: cfthread running condition?
I checked into using a join thread and at first glance it seemed perfect. But from the description in the docs, it seems to work the opposite of what I'd hoped. From the docs: The following code, for example, joins three threads to the current thread (often, the main thread). The current thread waits up to six seconds for the other threads to complete, and continues processing if one or more threads do not complete by then. cfthread action=join name=t1, t2, t3 timeout=6000/ From the description, it sounds like a join action causes threads that join a running thread to wait until the joining threads are complete before it finishes. I must admit, it's a little confusing. I thought it would work as you described, that the joining threads would wait until the thread they were joining was finished before processing. But the description makes it sound the other way around. ??? Rick -Original Message- From: joey krabacher [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 2:02 PM To: CF-Talk Subject: Re: cfthread running condition? You might be able to kick of the first thread (set the action to run) then have a list or something that you can loop over and have a join cfthread inside the loop with the same name as the first one. Something like this. cfthread action='run' name='t1' do something /cfthread cfloop index='i' from='1' to='50' cfthread action='join' name='t1' do something /cfthread /cfloop I have not tried this, but the 'join' action tells cf to wait for the named thread(t1) to finish. Joey Is there a way to make the start of one thread conditional upon the ending of a previous thread? I want to keep only one thread at a time running and would like to set up a series of threads to run, but only one at a time. I've been doing this with scheduled tasks and emailing completion to myself for verification of success each morning, but running 54 schedule task templates currently, with having to add another 30 or so soon has just become quite cumbersome. Didn't know if there were any options. Too bad we can't number the threads to run sequentially and set them to run only individually. Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311805 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: cfthread running condition?
I started another thread with a question about some code in the docs that used a sleep function and a status check to delay a thread's start, but the code in the waiting thread was in cfscript blocks and the processing was supposed to occur in the block. I haven't used cfscript so I asked if it was possible to just have the block run and then let the rest of the thread use regular CFML, but my data didn't get processed by that particular thread, but the data was processed by all other threads in the .cfm. Here's the question as I posted it: I'm trying to set up a way to check the status of threads and implement a sleep function that loops and delays a following thread's initialization until the status of the first thread is Completed. I found an example in the CF8 docs using a sleep timer this is placed just inside the opening cfthread... tag of the cfthread that needs to wait. cfscript thread.sleepTimes=0; thread.initialized=false; while ((2_hmls_offices.Status != COMPLETED) (2_hmls_offices.Status != TERMINATED)) { sleep(2000); thread.sleeptimes++; } // Only do the post-initilization code if 2_hmls_offices is complete. If (threadA.Status == COMPLETED) { thread.initialized=true; // Post-initialization code would go here. } /cfscript I understand what's happening inside the cfscript, but I'd like to continue the processing *outside* the cfscript tag and use regular CFML, not cfscript for the thread. This example states, in the last line //Post-initialization code would go here. Can I just use the cfscript as is and follow the cfscript block with my cfqueries, etc., or would all my thread processing have to occur within the cfscript block? Is there a way to break out of the cfscript block once the status of the first thread, 2_hmls_offices, is Completed and go on to process regular CFML code? Thanks, Rick -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 2:08 PM To: CF-Talk Subject: Re: cfthread running condition? Rick Faircloth wrote: Is there a way to make the start of one thread conditional upon the ending of a previous thread? It should be possible using the thread.status feature. You would create a thread then watch the status until it reports completed then start the next thread. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311806 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: cfthread running condition?
Rick Faircloth wrote: Is there a way to break out of the cfscript block once the status of the first thread, 2_hmls_offices, is Completed and go on to process regular CFML code? There is nothing special about the cfscript.../cfscript code. This is not a requirment of threads or anything, just a personal preference for coding style. The entire example could easily be rewritten using tag syntax. cfset thread.seepTimes = 0 cfset thread.initalized = false cfloop condition=2_hmls_officesstatus NEQ 'COMPLTETED' AND 2_htmls_offices.Status NEQ 'TERMINATED' cfset sleep(2000) cfset thread.sleeptimes++ /cfloop . Not syntax checked to make sure I translated that 100% correctly but you should get the idea. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311808 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfthread running condition?
In the docs under timeout it says: 'The number of milliseconds that the current thread waits for the thread or threads being joined to finish. If any thread does not finish by the specified time, the current thread proceeds. If the attribute value is 0, the following action occurs: * The current thread continues waiting until all joining threads finish. * If the current thread is the page thread, the page continues waiting until the threads are joined, even if you specify a page time-out.' This sounds like if you do not set the timeout attribute then the thread just waits until the joining thread finishes. I checked into using a join thread and at first glance it seemed perfect. But from the description in the docs, it seems to work the opposite of what I'd hoped. From the docs: The following code, for example, joins three threads to the current thread (often, the main thread). The current thread waits up to six seconds for the other threads to complete, and continues processing if one or more threads do not complete by then. cfthread action=join name=t1, t2, t3 timeout=6000/ From the description, it sounds like a join action causes threads that join a running thread to wait until the joining threads are complete before it finishes. I must admit, it's a little confusing. I thought it would work as you described, that the joining threads would wait until the thread they were joining was finished before processing. But the description makes it sound the other way around. ??? Rick -Original Message- From: joey krabacher [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 2:02 PM To: CF-Talk Subject: Re: cfthread running condition? You might be able to kick of the first thread (set the action to run) then have a list or something that you can loop over and have a join cfthread inside the loop with the same name as the first one. Something like this. cfthread action='run' name='t1' do something /cfthread cfloop index='i' from='1' to='50' cfthread action='join' name='t1' do something /cfthread /cfloop I have not tried this, but the 'join' action tells cf to wait for the named thread(t1) to finish. Joey Is there a way to make the start of one thread conditional upon the ending of a previous thread? I want to keep only one thread at a time running and would like to set up a series of threads to run, but only one at a time. I've been doing this with scheduled tasks and emailing completion to myself for verification of success each morning, but running 54 schedule task templates currently, with having to add another 30 or so soon has just become quite cumbersome. Didn't know if there were any options. Too bad we can't number the threads to run sequentially and set them to run only individually. Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311809 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: cfthread running condition?
I'm not too sure what constitutes a page thread. Assuming that it's the processing of the .cfm page, then that wouldn't really apply, I don't think, because I'd be using these merged templates with multiple threads coded in them as part of scheduled tasks, which, if I understand correctly wouldn't involve a page thread. I'm looking for a way to combine the 54 templates I currently have to process data every day into 4 or 5 templates. I actually tried setting the wait time to 0, and the template threw an error. When I set a time, it ran fine. Perhaps I should leave the wait time attribute out entirely. Perhaps that would default to 0. Also, even with the wait time set to 0, I don't want the joining threads to finish first...I want them to finish *after* the first thread that they would be joining. -Original Message- From: Joey Krabacher [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 4:20 PM To: CF-Talk Subject: Re: cfthread running condition? In the docs under timeout it says: 'The number of milliseconds that the current thread waits for the thread or threads being joined to finish. If any thread does not finish by the specified time, the current thread proceeds. If the attribute value is 0, the following action occurs: * The current thread continues waiting until all joining threads finish. * If the current thread is the page thread, the page continues waiting until the threads are joined, even if you specify a page time-out.' This sounds like if you do not set the timeout attribute then the thread just waits until the joining thread finishes. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311813 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: cfthread running condition?
I'm not too sure what constitutes a page thread. Assuming that it's the processing of the .cfm page, then that wouldn't really apply, I don't think, because I'd be using these merged templates with multiple threads coded in them as part of scheduled tasks, which, if I understand correctly wouldn't involve a page thread. The main thread is the one directly responding to the HTTP request. Scheduled tasks are HTTP requests. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311815 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: cfthread running condition?
But unlike a page thread that's running in a browser, the scheduled task page thread isn't subject to a timeout, right? -Original Message- From: Dave Watts [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 7:09 PM To: CF-Talk Subject: RE: cfthread running condition? I'm not too sure what constitutes a page thread. Assuming that it's the processing of the .cfm page, then that wouldn't really apply, I don't think, because I'd be using these merged templates with multiple threads coded in them as part of scheduled tasks, which, if I understand correctly wouldn't involve a page thread. The main thread is the one directly responding to the HTTP request. Scheduled tasks are HTTP requests. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311818 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: cfthread running condition?
But unlike a page thread that's running in a browser, the scheduled task page thread isn't subject to a timeout, right? Why wouldn't it be? It's just another HTTP request. Dave Watts, CTO, Fig Leaf Software ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311820 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfthread running condition?
Silly question - why not just run the executing code you want to fire to happen at the end of thread 1? It has exactly the same result, there is no need to create a whole new thread, as you can just continue in the one you are in. Mark On Sat, Aug 30, 2008 at 12:26 PM, Dave Watts [EMAIL PROTECTED] wrote: But unlike a page thread that's running in a browser, the scheduled task page thread isn't subject to a timeout, right? Why wouldn't it be? It's just another HTTP request. Dave Watts, CTO, Fig Leaf Software ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311828 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4