summaryrefslogtreecommitdiff
path: root/ACE/examples/APG/ThreadManagement/Async_Cancel.cpp
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 13:56:48 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 13:56:48 +0000
commitc4078c377d74290ebe4e66da0b4975da91732376 (patch)
tree1816ef391e42a07929304908ac0e21f4c2f6cb7b /ACE/examples/APG/ThreadManagement/Async_Cancel.cpp
parent700d1c1a6be348c6c70a2085e559baeb8f4a62ea (diff)
downloadATCD-c4078c377d74290ebe4e66da0b4975da91732376.tar.gz
swap in externals for ACE and TAO
Diffstat (limited to 'ACE/examples/APG/ThreadManagement/Async_Cancel.cpp')
-rw-r--r--ACE/examples/APG/ThreadManagement/Async_Cancel.cpp63
1 files changed, 0 insertions, 63 deletions
diff --git a/ACE/examples/APG/ThreadManagement/Async_Cancel.cpp b/ACE/examples/APG/ThreadManagement/Async_Cancel.cpp
deleted file mode 100644
index 842c7fa2bca..00000000000
--- a/ACE/examples/APG/ThreadManagement/Async_Cancel.cpp
+++ /dev/null
@@ -1,63 +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
-
-#else /* ACE_HAS_PTHREADS */
-int ACE_TMAIN (int, ACE_TCHAR *[])
-{
- ACE_OS::puts ("This example works on Pthreads platforms.\n");
- return 0;
-}
-#endif /* ACE_HAS_PTHREADS */
-