src/server/daemon/resourcepool.h

branch
webdav
changeset 272
f210681d9dd0
parent 269
3dfbd0b91950
child 415
d938228c382e
equal deleted inserted replaced
271:fd5765c5068c 272:f210681d9dd0
37 37
38 #ifdef __cplusplus 38 #ifdef __cplusplus
39 extern "C" { 39 extern "C" {
40 #endif 40 #endif
41 41
42 typedef struct ResourcePool ResourcePool;
43 typedef struct ResourceDataPrivate ResourceDataPrivate; 42 typedef struct ResourceDataPrivate ResourceDataPrivate;
44 43
45 struct ResourceDataPrivate { 44 struct ResourceDataPrivate {
46 ResourceData data; 45 ResourceData data;
47 Request *rq; 46
48 ResourceType *type; 47 /*
48 * the void* pointer returned by respool->type->createresource
49 *
50 * ResourceData.data contains the pointer returned by
51 * respool->type->getresourcedata(resdata))
52 */
53 void *resdata;
49 }; 54 };
50 55
51 struct ResourcePool { 56 struct ResourcePool {
52 /* 57 /*
53 * Memory pool 58 * Memory pool
73 78
74 /* 79 /*
75 * Array of available resources 80 * Array of available resources
76 * each entry is created with ResourceType.createresource 81 * each entry is created with ResourceType.createresource
77 */ 82 */
78 void **resources; 83 ResourceDataPrivate **resources;
79 84
80 /* 85 /*
81 * Allocated size of the resources array 86 * Allocated size of the resources array
82 */ 87 */
83 size_t resalloc; 88 size_t resalloc;
84 89
85 /* 90 /*
86 * Number of currently available resources in the array 91 * Number of currently available resources in the array
87 */ 92 */
88 size_t numresources; 93 size_t numresources;
94
95
96 /*
97 * Number of created resources (in use + available)
98 */
99 size_t numcreated;
89 100
90 /* 101 /*
91 * resource pool min parameter 102 * resource pool min parameter
92 */ 103 */
93 int min; 104 int min;
100 111
101 int init_resource_pools(void); 112 int init_resource_pools(void);
102 113
103 int resourcepool_new(ServerConfiguration *cfg, scstr_t type, scstr_t name, ConfigNode *node); 114 int resourcepool_new(ServerConfiguration *cfg, scstr_t type, scstr_t name, ConfigNode *node);
104 115
105 int resourcepool_create_resources(ResourcePool *pool, int num_res); 116 void resourcepool_destroy_resource(ResourceDataPrivate *res);
106 117
107 void resourcepool_destroy(ResourcePool *respool); 118 void resourcepool_destroy(ResourcePool *respool);
108 119
109 #ifdef __cplusplus 120 #ifdef __cplusplus
110 } 121 }

mercurial