1 /* 2 * Copyright 2010, Axel Dörfler. All Rights Reserved. 3 * Copyright 2007, Hugo Santos. All Rights Reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef _SLAB_OBJECT_DEPOT_H_ 7 #define _SLAB_OBJECT_DEPOT_H_ 8 9 10 #include <lock.h> 11 #include <KernelExport.h> 12 13 14 struct DepotMagazine; 15 16 typedef struct object_depot { 17 rw_lock outer_lock; 18 spinlock inner_lock; 19 DepotMagazine* full; 20 DepotMagazine* empty; 21 size_t full_count; 22 size_t empty_count; 23 size_t max_count; 24 size_t magazine_capacity; 25 struct depot_cpu_store* stores; 26 void* cookie; 27 28 void (*return_object)(struct object_depot* depot, void* cookie, 29 void* object, uint32 flags); 30 } object_depot; 31 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 status_t object_depot_init(object_depot* depot, size_t capacity, 38 size_t maxCount, uint32 flags, void* cookie, 39 void (*returnObject)(object_depot* depot, void* cookie, void* object, 40 uint32 flags)); 41 void object_depot_destroy(object_depot* depot, uint32 flags); 42 43 void* object_depot_obtain(object_depot* depot); 44 void object_depot_store(object_depot* depot, void* object, uint32 flags); 45 46 void object_depot_make_empty(object_depot* depot, uint32 flags); 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 53 #endif /* _SLAB_OBJECT_DEPOT_H_ */ 54