摘要 |
A method is disclosed for providing exception support in a computer having an operating system, the operating system providing application programming interfaces for use by a threads library to create, execute and cancel process threads. The threads library normally maintains a cleanup handler stack for each thread for use in effecting clean-up of state upon receipt of a thread cancel. The method begins when there is a predetermined exception handling macro associated with a current thread by pushing a pair of pointers onto the cleanup handler stack of that thread. The first pointer identifies a predetermined function and the second pointer identifies a particular exception context. Upon receipt of a thread cancel for the thread, the threads library invokes the predetermined function as a cleanup handler (with the exception context as its argument) to thereby map the thread cancel into an exception. The exception is then processed using an exception handling mechanism. The method advantageously enables the operating system to provide exception support for applications written to conform to the Distributed Computing Environment (DCE) standard even though the threads library does not otherwise support any mechanism for raising exceptions.
|