Reordered functions.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35199 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d66916e33b
commit
030a4ea6c9
@ -151,54 +151,6 @@ object_depot_cpu(object_depot* depot)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
status_t
|
||||
object_depot_init(object_depot* depot, uint32 flags, void* cookie,
|
||||
void (*return_object)(object_depot* depot, void* cookie, void* object))
|
||||
{
|
||||
depot->full = NULL;
|
||||
depot->empty = NULL;
|
||||
depot->full_count = depot->empty_count = 0;
|
||||
|
||||
recursive_lock_init(&depot->lock, "depot");
|
||||
|
||||
int cpuCount = smp_get_num_cpus();
|
||||
depot->stores = (depot_cpu_store*)slab_internal_alloc(
|
||||
sizeof(depot_cpu_store) * cpuCount, flags);
|
||||
if (depot->stores == NULL) {
|
||||
recursive_lock_destroy(&depot->lock);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cpuCount; i++) {
|
||||
recursive_lock_init(&depot->stores[i].lock, "cpu store");
|
||||
depot->stores[i].loaded = depot->stores[i].previous = NULL;
|
||||
}
|
||||
|
||||
depot->cookie = cookie;
|
||||
depot->return_object = return_object;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
object_depot_destroy(object_depot* depot)
|
||||
{
|
||||
object_depot_make_empty(depot);
|
||||
|
||||
int cpuCount = smp_get_num_cpus();
|
||||
for (int i = 0; i < cpuCount; i++)
|
||||
recursive_lock_destroy(&depot->stores[i].lock);
|
||||
|
||||
slab_internal_free(depot->stores);
|
||||
|
||||
recursive_lock_destroy(&depot->lock);
|
||||
}
|
||||
|
||||
|
||||
static void*
|
||||
object_depot_obtain_from_store(object_depot* depot, depot_cpu_store* store)
|
||||
{
|
||||
@ -252,6 +204,54 @@ object_depot_return_to_store(object_depot* depot, depot_cpu_store* store,
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - public API
|
||||
|
||||
|
||||
status_t
|
||||
object_depot_init(object_depot* depot, uint32 flags, void* cookie,
|
||||
void (*return_object)(object_depot* depot, void* cookie, void* object))
|
||||
{
|
||||
depot->full = NULL;
|
||||
depot->empty = NULL;
|
||||
depot->full_count = depot->empty_count = 0;
|
||||
|
||||
recursive_lock_init(&depot->lock, "depot");
|
||||
|
||||
int cpuCount = smp_get_num_cpus();
|
||||
depot->stores = (depot_cpu_store*)slab_internal_alloc(
|
||||
sizeof(depot_cpu_store) * cpuCount, flags);
|
||||
if (depot->stores == NULL) {
|
||||
recursive_lock_destroy(&depot->lock);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cpuCount; i++) {
|
||||
recursive_lock_init(&depot->stores[i].lock, "cpu store");
|
||||
depot->stores[i].loaded = depot->stores[i].previous = NULL;
|
||||
}
|
||||
|
||||
depot->cookie = cookie;
|
||||
depot->return_object = return_object;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
object_depot_destroy(object_depot* depot)
|
||||
{
|
||||
object_depot_make_empty(depot);
|
||||
|
||||
int cpuCount = smp_get_num_cpus();
|
||||
for (int i = 0; i < cpuCount; i++)
|
||||
recursive_lock_destroy(&depot->stores[i].lock);
|
||||
|
||||
slab_internal_free(depot->stores);
|
||||
|
||||
recursive_lock_destroy(&depot->lock);
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
object_depot_obtain(object_depot* depot)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user