1 /* ChvManager.h */ 2 3 #include "../Chv.h" 4 #include "../Lock.h" 5 6 /*--------------------------------------------------------------------*/ 7 /* 8 */ 9 typedef struct _ChvManager ChvManager ; 10 struct _ChvManager { 11 Chv *head ; 12 Lock *lock ; 13 int mode ; 14 int nactive ; 15 int nbytesactive ; 16 int nbytesrequested ; 17 int nbytesalloc ; 18 int nrequests ; 19 int nreleases ; 20 int nlocks ; 21 int nunlocks ; 22 } ; 23 /*--------------------------------------------------------------------*/ 24 /* 25 ------------------------------------------------------------------------ 26 ----- methods found in basics.c ---------------------------------------- 27 ------------------------------------------------------------------------ 28 */ 29 /* 30 ----------------------- 31 simplest constructor 32 33 created -- 98may02, cca 34 ----------------------- 35 */ 36 ChvManager * 37 ChvManager_new ( 38 void 39 ) ; 40 /* 41 ----------------------- 42 set the default fields 43 44 created -- 98may02, cca 45 ----------------------- 46 */ 47 void 48 ChvManager_setDefaultFields ( 49 ChvManager *manager 50 ) ; 51 /* 52 -------------------------------------------------- 53 clear the data fields, releasing allocated storage 54 55 created -- 98may02, cca 56 -------------------------------------------------- 57 */ 58 void 59 ChvManager_clearData ( 60 ChvManager *manager 61 ) ; 62 /* 63 ------------------------------------------ 64 destructor, free's the object and its data 65 66 created -- 98may02, cca 67 ------------------------------------------ 68 */ 69 void 70 ChvManager_free ( 71 ChvManager *manager 72 ) ; 73 /*--------------------------------------------------------------------*/ 74 /* 75 ------------------------------------------------------------------------ 76 ----- methods found in init.c ------------------------------------------ 77 ------------------------------------------------------------------------ 78 */ 79 /* 80 --------------------------------------------------------------- 81 simple initializer 82 83 lockflag = 0 --> mutex lock is not allocated or initialized 84 lockflag = 1 --> mutex lock is allocated and it can synchronize 85 only threads in this process. 86 lockflag = 2 --> mutex lock is allocated and it can synchronize 87 only threads in this and other processes. 88 89 mode = 0 --> free object and storage on release 90 mode = 1 --> recycle object and storage on release 91 92 created -- 98may02, cca 93 --------------------------------------------------------------- 94 */ 95 void 96 ChvManager_init ( 97 ChvManager *manager, 98 int lockflag, 99 int mode 100 ) ; 101 /*--------------------------------------------------------------------*/ 102 /* 103 ------------------------------------------------------------------------ 104 ----- methods found in util.c ------------------------------------------ 105 ------------------------------------------------------------------------ 106 */ 107 /* 108 ------------------------------------------ 109 return a pointer to a Chv object that has 110 been initialized with the input parameters 111 112 created -- 98may02, cca 113 ------------------------------------------ 114 */ 115 Chv * 116 ChvManager_newObject ( 117 ChvManager *manager, 118 int id, 119 int nD, 120 int nL, 121 int nU, 122 int symflag 123 ) ; 124 /* 125 ------------------------------------------ 126 return a pointer to a Chv object that has 127 been initialized with the input parameters 128 129 created -- 98may02, cca 130 ------------------------------------------ 131 */ 132 Chv * 133 ChvManager_newObjectOfSizeNbytes ( 134 ChvManager *manager, 135 int nbytesNeeded 136 ) ; 137 /* 138 ----------------------- 139 release a Chv instance 140 141 created -- 98may02, cca 142 ----------------------- 143 */ 144 void 145 ChvManager_releaseObject ( 146 ChvManager *manager, 147 Chv *chv 148 ) ; 149 /* 150 ------------------------------ 151 release a list of Chv objects 152 153 created -- 98may02, cca 154 ------------------------------ 155 */ 156 void 157 ChvManager_releaseListOfObjects ( 158 ChvManager *manager, 159 Chv *head 160 ) ; 161 /*--------------------------------------------------------------------*/ 162 /* 163 ------------------------------------------------------------------------ 164 ----- methods found in IO.c -------------------------------------------- 165 ------------------------------------------------------------------------ 166 */ 167 /* 168 ---------------------------------------- 169 purpose -- to write the object to a file 170 in human readable form 171 172 created -- 98may02, cca 173 ---------------------------------------- 174 */ 175 void 176 ChvManager_writeForHumanEye ( 177 ChvManager *manager, 178 FILE *fp 179 ) ; 180 /*--------------------------------------------------------------------*/ 181