[M3devel] RegisterFinalCleanup and locking?

Jay K jay.krell at cornell.edu
Tue Dec 15 04:01:55 CET 2009


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.

Some sort of reserve/commit, reserve/cancel system.

 

 

Like:

   cleanup := ReserveFinalCleanup(); (* can fail with exception*)

   cleanup.object := mutex;

   cleanup.function := CleanMutex;

    ...

   CommitFinalCleanup(cleanup); (* cannot fail *)

or

   CancelFinalCleanup(cleanup); (* cannot fail *)

 

 

I think it might not be at all difficult.

 

 

Or:

   cleanup := ReserveFinalCleanup(); (* can fail with exception *)

..

  CommitFinalCleanup(cleanup, mutex, CleanMutex);

or

  CancelFinalCleanup(cleanup);

 

 

or:

   cleanup := ReserveFinalCleanup(mutex, CleanMutex); (* can fail with exception *)

 and then optional CancelFinalCleanup(cleanup);

 

 

but not sure the last one is viable.

 

 

Maybe:

  UnsafeCollectNow(mutex);

?

 

 

Hm. Do we have that already? DISPOSE on traced references in unsafe code?

And it does or does not handle the registered cleanup? I'll check.

 

 

 

 - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091215/0b4bf888/attachment-0001.html>


More information about the M3devel mailing list