mdcore
0.1.5
|
00001 /******************************************************************************* 00002 * This file is part of mdcore. 00003 * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk) 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published 00007 * by the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 ******************************************************************************/ 00019 00020 /* queue error codes */ 00021 #define queue_err_ok 0 00022 #define queue_err_null -1 00023 #define queue_err_malloc -2 00024 #define queue_err_full -3 00025 #define queue_err_lock -4 00026 00027 00028 /* some constants */ 00029 #define queue_flag_pairs 1 00030 #define queue_flag_tuples 2 00031 00032 00034 extern int queue_err; 00035 00036 00038 struct queue { 00039 00040 /* Queue flags. */ 00041 unsigned int flags; 00042 00043 /* Allocated size. */ 00044 int size; 00045 00046 /* The queue data. */ 00047 union { 00048 struct cellpair *pairs; 00049 struct celltuple *tuples; 00050 } data; 00051 00052 /* The space in which this queue lives. */ 00053 struct space *space; 00054 00055 /* The queue indices. */ 00056 int *ind; 00057 00058 /* Index of next entry. */ 00059 int next; 00060 00061 /* Index of last entry. */ 00062 int count; 00063 00064 /* Lock for this queue. */ 00065 lock_type lock; 00066 00067 }; 00068 00069 00070 /* Associated functions */ 00071 int queue_pairs_init ( struct queue *q , int size , struct space *s , struct cellpair *pairs ); 00072 int queue_tuples_init ( struct queue *q , int size , struct space *s , struct celltuple *tuples ); 00073 void queue_reset ( struct queue *q ); 00074 int queue_insert ( struct queue *q , void *thing ); 00075 void *queue_get ( struct queue *q , int rid , int keep );