diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-06-18 18:53:27 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-06-18 18:53:27 +0000 |
commit | 152c0f5c127eac99b5c9097aa4db2b34e14e6dd0 (patch) | |
tree | 0d399a92623e98588cd34e4fe0c2cf7fed880173 /examples/APG/ThreadManagement/Async_Cancel.cpp | |
parent | 7e7f4a5d3e77a42e648b7dd2e1b9cf23a3780955 (diff) | |
download | ATCD-MyACE.tar.gz |
This commit was manufactured by cvs2svn to create branch 'MyACE'.MyACE
Diffstat (limited to 'examples/APG/ThreadManagement/Async_Cancel.cpp')
-rw-r--r-- | examples/APG/ThreadManagement/Async_Cancel.cpp | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/examples/APG/ThreadManagement/Async_Cancel.cpp b/examples/APG/ThreadManagement/Async_Cancel.cpp deleted file mode 100644 index 6e05d65ec0b..00000000000 --- a/examples/APG/ThreadManagement/Async_Cancel.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// $Id$ - -#include "ace/OS_NS_unistd.h" -#include "ace/Task.h" -#include "ace/Log_Msg.h" - -#if defined (ACE_HAS_PTHREADS) -// Only works on Pthreads... - -// Listing 1 code/ch13 -class CanceledTask : public ACE_Task<ACE_MT_SYNCH> -{ -public: - virtual int svc (void) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Starting thread\n"))); - - if (this->set_cancel_mode () < 0) - return -1; - - while (1) - { - // Put this thread in a compute loop.. no - // cancellation points are available. - } - } - - int set_cancel_mode (void) - { - cancel_state new_state; - - // Set the cancel state to asynchronous and enabled. - new_state.cancelstate = PTHREAD_CANCEL_ENABLE; - new_state.canceltype = PTHREAD_CANCEL_ASYNCHRONOUS; - if (ACE_Thread::setcancelstate (new_state, 0) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("cancelstate")), -1); - return 0; - } -}; -// Listing 1 -// Listing 2 code/ch13 -int ACE_TMAIN (int, ACE_TCHAR *[]) -{ - CanceledTask task; - task.activate (); - ACE_OS::sleep (1); - ACE_Thread_Manager::instance ()->cancel_task (&task, 1); - task.wait (); - - return 0; -} -// Listing 2 - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Task<ACE_MT_SYNCH>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -pragma instantiate ACE_Task<ACE_MT_SYNCH>; -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - -#else /* ACE_HAS_PTHREADS */ -int ACE_TMAIN (int, ACE_TCHAR *[]) -{ - puts ("This example works on Pthreads platforms.\n"); - return 0; -} -#endif /* ACE_HAS_PTHREADS */ - |