<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
I think RegisterFinalCleanup should be augmented or changed so that caller can use it without holding a lock, thereby avoiding holding two locks (RegisterFinalCleanup uses heap lock) and worrying about the order/deadlock.<BR>
Some sort of reserve/commit, reserve/cancel system.<BR>
<BR>
<BR>
Like:<BR>
cleanup := ReserveFinalCleanup(); (* can fail with exception*)<BR>
cleanup.object := mutex;<BR>
cleanup.function := CleanMutex;<BR>
...<BR>
CommitFinalCleanup(cleanup); (* cannot fail *)<BR>
or<BR>
CancelFinalCleanup(cleanup); (* cannot fail *)<BR>
<BR>
<BR>
I think it might not be at all difficult.<BR>
<BR>
<BR>
Or:<BR>
cleanup := ReserveFinalCleanup(); (* can fail with exception *)<BR>
..<BR>
CommitFinalCleanup(cleanup, mutex, CleanMutex);<BR>
or<BR>
CancelFinalCleanup(cleanup);<BR>
<BR>
<BR>
or:<BR>
cleanup := ReserveFinalCleanup(mutex, CleanMutex); (* can fail with exception *)<BR>
and then optional CancelFinalCleanup(cleanup);<BR>
<BR>
<BR>
but not sure the last one is viable.<BR>
<BR>
<BR>
Maybe:<BR>
UnsafeCollectNow(mutex);<BR>
?<BR>
<BR>
<BR>
Hm. Do we have that already? DISPOSE on traced references in unsafe code?<BR>
And it does or does not handle the registered cleanup? I'll check.<BR>
<BR>
<BR>
<BR>
- Jay<BR><BR> </body>
</html>