home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / java.z / finalize.h < prev    next >
C/C++ Source or Header  |  1996-05-03  |  3KB  |  70 lines

  1. /*
  2.  * @(#)finalize.h    1.10 96/03/20
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. #ifndef _FINALIZE_H_
  21. #define _FINALIZE_H_
  22.  
  23. #include "oobj.h"
  24. #include "sys_api.h"
  25.  
  26. /*
  27.  * The HasFinalizerQ and FinalizeMeQ queues contain finalizer_t
  28.  * structures.  The next field must be the first field in the struct,
  29.  * and handles rather than objects are used to avoid relocating the
  30.  * contents of the queues on GC.
  31.  */
  32. typedef struct finalizer_t {
  33.     struct finalizer_t *next;    /* The next finalizer structure */
  34.     JHandle *handle;        /* The handle of the object */
  35. } finalizer_t;
  36.  
  37. extern finalizer_t *HasFinalizerQ;
  38. extern finalizer_t *FinalizeMeQ;
  39. extern finalizer_t *BeingFinalized;
  40.  
  41.  
  42. /*
  43.  * Locks for the finalization queues
  44.  */
  45. extern sys_mon_t *_hasfinalq_lock;
  46. #define HASFINALQ_LOCK_INIT()    monitorRegister(_hasfinalq_lock, \
  47.                         "Has finalization queue lock")
  48. #define HASFINALQ_LOCK()    sysMonitorEnter(_hasfinalq_lock)
  49. #define HASFINALQ_LOCKED()    sysMonitorEntered(_hasfinalq_lock)
  50. #define HASFINALQ_UNLOCK()    sysMonitorExit(_hasfinalq_lock)
  51. #define HASFINALQ_NOTIFY()    sysMonitorNotify(_hasfinalq_lock)
  52. #define HASFINALQ_WAIT()    sysMonitorWait(_hasfinalq_lock, \
  53.                            TIMEOUT_INFINITY)
  54. extern sys_mon_t *_finalmeq_lock;
  55. #define FINALMEQ_LOCK_INIT()    monitorRegister(_finalmeq_lock, \
  56.                         "Finalize me queue lock")
  57. #define FINALMEQ_LOCK()        sysMonitorEnter(_finalmeq_lock)
  58. #define FINALMEQ_LOCKED()    sysMonitorEntered(_finalmeq_lock)
  59. #define FINALMEQ_UNLOCK()    sysMonitorExit(_finalmeq_lock)
  60. #define FINALMEQ_NOTIFY()    sysMonitorNotify(_finalmeq_lock)
  61. #define FINALMEQ_WAIT()        sysMonitorWait(_finalmeq_lock, \
  62.                            TIMEOUT_INFINITY)
  63.  
  64. extern void InitializeFinalizer(void);
  65. extern void InitializeFinalizerThread(void);
  66.  
  67. extern void runFinalization(void);
  68.  
  69. #endif /* _FINALIZE_H_ */
  70.