haiku/headers/private/kernel/slab/ObjectDepot.h
Axel Dörfler ff59ce680d * The low resource handler now empties the cache depot's magazines; before,
they were never freed unless the cache was destroyed (I just wondered why
  my system would bury >1G in the magazines).
* Made the magazine capacity variable per cache, ie. for larger objects, it's
  not a good idea to have 64*CPU buffers lying around in the worst case.
* Furthermore, the create_object_cache_etc()/object_depot_init() now have
  arguments for the magazine capacity as well as the maximum number of full
  unused magazines.
* By default, you might want to initialize both to zero, as then some hopefully
  usable defaults are computed. Otherwise (the only current example is the
  vm_page_mapping cache) you can just put in the values you'd want there.
  The page mapping cache uses larger values, as its objects are usually
  allocated and deleted in larger chunks.
* Beware, though, I couldn't test these changes yet as Qemu didn't like to run
  today. I'll test these changes on another machine now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-24 14:43:20 +00:00

54 lines
1.2 KiB
C

/*
* Copyright 2010, Axel Dörfler. All Rights Reserved.
* Copyright 2007, Hugo Santos. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SLAB_OBJECT_DEPOT_H_
#define _SLAB_OBJECT_DEPOT_H_
#include <lock.h>
#include <KernelExport.h>
struct DepotMagazine;
typedef struct object_depot {
rw_lock outer_lock;
spinlock inner_lock;
DepotMagazine* full;
DepotMagazine* empty;
size_t full_count;
size_t empty_count;
size_t max_count;
size_t magazine_capacity;
struct depot_cpu_store* stores;
void* cookie;
void (*return_object)(struct object_depot* depot, void* cookie,
void* object, uint32 flags);
} object_depot;
#ifdef __cplusplus
extern "C" {
#endif
status_t object_depot_init(object_depot* depot, size_t capacity,
size_t maxCount, uint32 flags, void* cookie,
void (*returnObject)(object_depot* depot, void* cookie, void* object,
uint32 flags));
void object_depot_destroy(object_depot* depot, uint32 flags);
void* object_depot_obtain(object_depot* depot);
int object_depot_store(object_depot* depot, void* object, uint32 flags);
void object_depot_make_empty(object_depot* depot, uint32 flags);
#ifdef __cplusplus
}
#endif
#endif /* _SLAB_OBJECT_DEPOT_H_ */