00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the 00007 * "License"); you may not use this file except in compliance 00008 * with the License. You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, 00013 * software distributed under the License is distributed on an 00014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00015 * KIND, either express or implied. See the License for the 00016 * specific language governing permissions and limitations 00017 * under the License. 00018 */ 00019 00020 #ifndef _GUAC_POOL_H 00021 #define _GUAC_POOL_H 00022 00030 #include "pool-types.h" 00031 00032 #include <pthread.h> 00033 00034 struct guac_pool { 00035 00041 int min_size; 00042 00046 int active; 00047 00052 int __next_value; 00053 00057 guac_pool_int* __head; 00058 00062 guac_pool_int* __tail; 00063 00067 pthread_mutex_t __lock; 00068 00069 }; 00070 00071 struct guac_pool_int { 00072 00076 int value; 00077 00082 guac_pool_int* __next; 00083 00084 }; 00085 00094 guac_pool* guac_pool_alloc(int size); 00095 00101 void guac_pool_free(guac_pool* pool); 00102 00116 int guac_pool_next_int(guac_pool* pool); 00117 00130 void guac_pool_free_int(guac_pool* pool, int value); 00131 00132 #endif 00133