haiku/headers/private/kernel/slab/ObjectDepot.h
Ingo Weinhold 453a2bdd18 Replaced the locking strategy (formerly a recursive lock for the depot and
one for each per CPU store):
* The depot is now protected by a R/W lock combined with a spinlock. It is
  required to either hold read lock + spinlock or just the write lock.
* When accessing the per CPU stores we only need to acquire the read lock
  and disable interrupts. When switching magazines with the depot we
  additionally get the spinlock.
* When allocating a new magazine we do completely unlock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35200 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-20 13:00:57 +00:00

48 lines
1.0 KiB
C

/*
* 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;
struct depot_cpu_store* stores;
void* cookie;
void (*return_object)(struct object_depot* depot, void* cookie,
void* object);
} object_depot;
#ifdef __cplusplus
extern "C" {
#endif
status_t object_depot_init(object_depot* depot, uint32 flags, void* cookie,
void (*returnObject)(object_depot* depot, void* cookie, void* object));
void object_depot_destroy(object_depot* depot);
void* object_depot_obtain(object_depot* depot);
int object_depot_store(object_depot* depot, void* object);
void object_depot_make_empty(object_depot* depot);
#ifdef __cplusplus
}
#endif
#endif /* _SLAB_OBJECT_DEPOT_H_ */