2007-04-26 03:41:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2007, Hugo Santos. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2010-01-19 10:12:48 +00:00
|
|
|
#ifndef _SLAB_OBJECT_DEPOT_H_
|
|
|
|
#define _SLAB_OBJECT_DEPOT_H_
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2008-02-02 12:12:54 +00:00
|
|
|
|
2007-04-26 03:41:24 +00:00
|
|
|
#include <lock.h>
|
2007-04-28 21:35:23 +00:00
|
|
|
#include <KernelExport.h>
|
2007-04-26 03:41:24 +00:00
|
|
|
|
|
|
|
|
2010-01-19 19:13:25 +00:00
|
|
|
struct DepotMagazine;
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2010-01-19 19:13:25 +00:00
|
|
|
typedef struct object_depot {
|
2010-01-20 13:00:57 +00:00
|
|
|
rw_lock outer_lock;
|
|
|
|
spinlock inner_lock;
|
2010-01-19 19:13:25 +00:00
|
|
|
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);
|
2007-04-28 21:35:23 +00:00
|
|
|
} object_depot;
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
|
2008-02-02 12:12:54 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-01-19 20:36:29 +00:00
|
|
|
status_t object_depot_init(object_depot* depot, uint32 flags, void* cookie,
|
2010-01-19 19:13:25 +00:00
|
|
|
void (*returnObject)(object_depot* depot, void* cookie, void* object));
|
|
|
|
void object_depot_destroy(object_depot* depot);
|
2007-04-28 18:53:58 +00:00
|
|
|
|
2010-01-19 19:13:25 +00:00
|
|
|
void* object_depot_obtain(object_depot* depot);
|
|
|
|
int object_depot_store(object_depot* depot, void* object);
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2010-01-19 19:13:25 +00:00
|
|
|
void object_depot_make_empty(object_depot* depot);
|
2007-04-26 03:41:24 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-19 10:12:48 +00:00
|
|
|
#endif /* _SLAB_OBJECT_DEPOT_H_ */
|