> I have just discovered a serious issue within the core > architecture of this beast of a program that I have > written using threads... > > I am using Thread::Queue to throttle resources from the > jobs that have to be done at any given time. > > This program, collects information from a database, maps a > drive using OLE calls, and copies the files to the > destination drive and it does this part well. The problem > is, some of my servers are dial up... I have no issues > making modem calls but sometimes I get disconnected during > the copy phase which causes my threads to hold up and not > release its resource back to the queue for the next job... > > I am limited on resources for the jobs... > > Right now, I am simply passing the job off to a thread and > detaching it... If for some reason, like being > disconnected from the server, the thread hangs out there > in lala land and never returns it resource back to the > resource queue for the next job, causing a major > bottleneck in my program. > > I am inquiring about a possible solution to monitor either > connection status to my destination server, or a thread > timeout so that I can catch the resource and put it back > in the queue for the next job. > > Is there a way to do a thread timeout? If a thread > doesn't respond within so many seconds, then run this > function?
There is no 'thread timeout' functionality per se. Further, there is no 'thread cancellation' functionality. Therefore, threads must monitor their own activity and time themselves out, if required. Note that you cannot use alarm() for this purpose. If IO is involved, you need to use select() with an appropriate timeout to accomplish your purpose.
