|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2006-03-02 08:41:42
Roland Schwarz <roland.schwarz_at_[hidden]> writes:
> Another point: Anthony is proposing (as I understood) to have a mutex
> without
> a destructor. Hmm, how would one release the system mutex resource then?
I am proposing that we have a mutex type without a destructor, *in addition*
to one with a destructor, for mutexes with static storage duration. Such a
mutex will be cleaned up automatically by Windows on program exit:
"When a process terminates, the system automatically closes handles and
deletes objects created by the process" (from System Services/Windows System
Information/Handles and Objects/About Handles and Objects/Object Interface in
the platform SDK docs)
It is legal to destroy a locked mutex object. The assert does not check for
that case --- it checks whether CloseHandle failed. CloseHandle will fail if
the handle is invalid, which therefore indicates a corrupt system, so it is a
good idea to terminate the app.
Anthony
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk