(file) Return to Thread.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

 1 mday  1.1.2.1 //%/////////////////////////////////////////////////////////////////////////////
 2               //
 3               // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
 4               //
 5               // Permission is hereby granted, free of charge, to any person obtaining a copy
 6               // of this software and associated documentation files (the "Software"), to 
 7               // deal in the Software without restriction, including without limitation the 
 8               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
 9               // sell copies of the Software, and to permit persons to whom the Software is
10               // furnished to do so, subject to the following conditions:
11               // 
12               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
13               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
16               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
17               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
18               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20               //
21               //==============================================================================
22 mday  1.1.2.1 //
23 mday  1.1.2.2 // Author: Mike Day (mdday@us.ibm.com)
24 mday  1.1.2.1 //
25 mday  1.1.2.2 // Modified By: 
26 mday  1.1.2.1 //
27               //%/////////////////////////////////////////////////////////////////////////////
28               
29               #include "Thread.h"
30               
31               #if defined(PEGASUS_OS_TYPE_WINDOWS)
32               # include "ThreadWindows.cpp"
33               #elif defined(PEGASUS_OS_TYPE_UNIX)
34               # include "ThreadUnix.cpp"
35               #else
36               # error "Unsupported platform"
37               #endif
38               
39               PEGASUS_NAMESPACE_BEGIN
40               
41               
42               // for non-native implementations
43               #ifndef PEGASUS_THREAD_CLEANUP_NATIVE 
44               void Thread::cleanup_push( void (*routine)(void *), void *parm) throw(IPCException)
45               {
46                 cleanup_handler *cu = new cleanup_handler(routine, parm);
47 mday  1.1.2.1   try { _cleanup.insert_first(cu); } 
48                 catch(IPCException& e) { delete cu; throw; }
49                 return;
50               }
51               
52               void Thread::cleanup_pop(Boolean execute = true) throw(IPCException)
53               {
54                 cleanup_handler *cu ;
55                 try { cu = _cleanup.remove_first() ;}
56                 catch(IPCException& e) { assert(0); }
57                 if(execute == true)
58                   cu->execute();
59                 delete cu;
60               }
61               
62 mday  1.1.2.2 thread_data *Thread::put_tsd(Sint8 *key, void (*delete_func)(void *), Uint32 size, void *value) throw(IPCException)
63               {
64                 PEGASUS_ASSERT(key != NULL);
65                 PEGASUS_ASSERT(delete_func != NULL);
66                 thread_data *tsd ;
67                 tsd = _tsd.remove((void *)key);  // may throw an IPC exception 
68                 thread_data *ntsd = new thread_data(key);
69                 ntsd->put_data(delete_func, size, value);
70                 try { _tsd.insert_first(ntsd); }
71                 catch(IPCException& e) { delete ntsd; throw; }
72                 return(tsd);
73               }
74               
75               #endif
76               
77               #ifndef PEGASUS_THREAD_CLEANUP_NATIVE 
78               void Thread::exit_self(PEGASUS_THREAD_RETURN exit_code) 
79               { 
80                 // execute the cleanup stack and then return 
81                 while( _cleanup.count(); )
82                 {
83 mday  1.1.2.2     try { cleanup_pop(true); }
84                   catch(IPCException& e) { PEGASUS_ASSERT(0) ; break; } 
85                 }
86                 _exit_code = exit_code;
87               }
88 mday  1.1.2.1 #endif
89 mday  1.1.2.2 
90 mday  1.1.2.1 
91               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2