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