home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / alloc_cache.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  1KB  |  56 lines

  1. /*
  2.  * @(#)alloc_cache.h    1.3 97/10/07
  3.  * 
  4.  * Copyright 1993-1997 Sun Microsystems, Inc. 901 San Antonio Road, 
  5.  * Palo Alto, California, 94303, U.S.A.  All Rights Reserved.
  6.  * 
  7.  * This software is the confidential and proprietary information of Sun
  8.  * Microsystems, Inc. ("Confidential Information").  You shall not
  9.  * disclose such Confidential Information and shall use it only in
  10.  * accordance with the terms of the license agreement you entered into
  11.  * with Sun.
  12.  * 
  13.  * CopyrightVersion 1.2
  14.  * 
  15.  */
  16.  
  17. /*
  18.  * Per-thread allocation cache
  19.  */
  20.  
  21. #ifndef    _ALLOC_CACHE_H_
  22. #define    _ALLOC_CACHE_H_
  23.  
  24. /* Default cache (refill) size */
  25. #define    ALLOC_CACHE_SIZE    1024
  26. /* Default maximum local allocation size, must be less than cache size */
  27. #define    ALLOC_LOCAL_SIZE    (ALLOC_CACHE_SIZE/4)
  28. /* Default handle cache refill count */
  29. #define    ALLOC_HANDLE_COUNT    (ALLOC_CACHE_SIZE/8/3)
  30.  
  31. /*
  32.  * Per-thread structure
  33.  */
  34. struct alloc_cache {
  35.     char    cache_busy;
  36.     char    cache_pad[3];
  37.     long    cache_size;
  38.     void    *cache_tail;
  39.     void    *cache_handles;
  40. };
  41.  
  42. /* Cache (refill) size */
  43. extern long allocCacheSize;
  44.  
  45. /* Allocations smaller than this are attempted from local cache.  Use
  46.    0 to turn off local allocation.  Must be less than cache size. */
  47. extern long allocLocalSize;
  48.  
  49. /* Cache handle refill count */
  50. extern long allocHandleCount;
  51.  
  52. /* Callback when thread exits */
  53. extern void allocCacheCleanup(struct alloc_cache *);
  54.  
  55. #endif /* _ALLOC_CACHE_H */
  56.