libguac  0.9.13-incubating
pool.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef _GUAC_POOL_H
21 #define _GUAC_POOL_H
22 
30 #include "pool-types.h"
31 
32 #include <pthread.h>
33 
34 struct guac_pool {
35 
41  int min_size;
42 
46  int active;
47 
52  int __next_value;
53 
57  guac_pool_int* __head;
58 
62  guac_pool_int* __tail;
63 
67  pthread_mutex_t __lock;
68 
69 };
70 
71 struct guac_pool_int {
72 
76  int value;
77 
82  guac_pool_int* __next;
83 
84 };
85 
94 guac_pool* guac_pool_alloc(int size);
95 
101 void guac_pool_free(guac_pool* pool);
102 
116 int guac_pool_next_int(guac_pool* pool);
117 
130 void guac_pool_free_int(guac_pool* pool, int value);
131 
132 #endif
133 
int guac_pool_next_int(guac_pool *pool)
Returns the next available integer from the given guac_pool.
guac_pool * guac_pool_alloc(int size)
Allocates a new guac_pool having the given minimum size.
int min_size
The minimum number of integers which must have been returned by guac_pool_next_int before previously-...
Definition: pool.h:41
Represents a single integer within a larger pool of integers.
Definition: pool.h:71
void guac_pool_free(guac_pool *pool)
Frees the given guac_pool.
int active
The number of integers currently in use.
Definition: pool.h:46
Type definitions related to the guac_pool pool of unique integers.
A pool of integers.
Definition: pool.h:34
void guac_pool_free_int(guac_pool *pool, int value)
Frees the given integer back into the given guac_pool.
int value
The integer value of this pool entry.
Definition: pool.h:76