[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Use of Thread::Cancel
From: |
Matt Scifo |
Subject: |
Use of Thread::Cancel |
Date: |
Mon, 17 Nov 2003 17:15:38 -0800 |
Hello
I am having some problems understanding exactly how to cancel a thread.
I want to be able to issue a cancel request to a thread from another
thread (not a parent) and have it cancel only if it has not reached a
certain execution point. If that point has been reached, then the
cancel shouldn't be performed until a set point.
The docs talk about using cancelDeferred and setting a cancellation
point "such as yield". I'm not quite sure how to set a specific
cancellation point.
Here is some exmaple code that shows what I am trying to do...
while(!stop_running)
{
if (!_module_queue->empty())
{
void *target;
// _module_queue is a class derived from Buffer.
// This call blocks until something has been posted
// to the queue.
//
// Do not cancel beyond this point until cancellation
// point has been reached!
_module_queue->wait(&target);
while(start_important_operations_with_target)
{
// do not process a cancel() request until this
// block finishes.
}
// set cancellation point here.
// cancel() can now take affect.
}
}
Can anyone offer any insight?
I am using RH9, g++ 2.9.6, and commoncpp2 v1.0.13.
Thanks
Matt Scifo
- Use of Thread::Cancel,
Matt Scifo <=