mirror of https://github.com/yandex/odyssey.git
odissey: add client pending pool
This commit is contained in:
parent
a1b1605771
commit
90a0e764cb
|
@ -30,10 +30,12 @@
|
||||||
|
|
||||||
void od_clientpool_init(od_clientpool_t *p)
|
void od_clientpool_init(od_clientpool_t *p)
|
||||||
{
|
{
|
||||||
p->count_active = 0;
|
p->count_active = 0;
|
||||||
p->count_queue = 0;
|
p->count_queue = 0;
|
||||||
|
p->count_pending = 0;
|
||||||
od_listinit(&p->active);
|
od_listinit(&p->active);
|
||||||
od_listinit(&p->queue);
|
od_listinit(&p->queue);
|
||||||
|
od_listinit(&p->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
void od_clientpool_set(od_clientpool_t *p, od_client_t *client,
|
void od_clientpool_set(od_clientpool_t *p, od_client_t *client,
|
||||||
|
@ -50,6 +52,9 @@ void od_clientpool_set(od_clientpool_t *p, od_client_t *client,
|
||||||
case OD_CQUEUE:
|
case OD_CQUEUE:
|
||||||
p->count_queue--;
|
p->count_queue--;
|
||||||
break;
|
break;
|
||||||
|
case OD_CPENDING:
|
||||||
|
p->count_pending--;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
od_list_t *target = NULL;
|
od_list_t *target = NULL;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -63,6 +68,10 @@ void od_clientpool_set(od_clientpool_t *p, od_client_t *client,
|
||||||
target = &p->queue;
|
target = &p->queue;
|
||||||
p->count_queue++;
|
p->count_queue++;
|
||||||
break;
|
break;
|
||||||
|
case OD_CPENDING:
|
||||||
|
target = &p->pending;
|
||||||
|
p->count_pending++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
od_listunlink(&client->link_pool);
|
od_listunlink(&client->link_pool);
|
||||||
od_listinit(&client->link_pool);
|
od_listinit(&client->link_pool);
|
||||||
|
@ -82,6 +91,9 @@ od_clientpool_next(od_clientpool_t *p, od_clientstate_t state)
|
||||||
case OD_CQUEUE:
|
case OD_CQUEUE:
|
||||||
target = &p->queue;
|
target = &p->queue;
|
||||||
break;
|
break;
|
||||||
|
case OD_CPENDING:
|
||||||
|
target = &p->pending;
|
||||||
|
break;
|
||||||
case OD_CUNDEF:
|
case OD_CUNDEF:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,8 +12,10 @@ typedef struct od_clientpool_t od_clientpool_t;
|
||||||
struct od_clientpool_t {
|
struct od_clientpool_t {
|
||||||
od_list_t active;
|
od_list_t active;
|
||||||
od_list_t queue;
|
od_list_t queue;
|
||||||
|
od_list_t pending;
|
||||||
int count_active;
|
int count_active;
|
||||||
int count_queue;
|
int count_queue;
|
||||||
|
int count_pending;
|
||||||
};
|
};
|
||||||
|
|
||||||
void od_clientpool_init(od_clientpool_t*);
|
void od_clientpool_init(od_clientpool_t*);
|
||||||
|
@ -24,7 +26,8 @@ od_clientpool_next(od_clientpool_t*, od_clientstate_t);
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
od_clientpool_total(od_clientpool_t *pool) {
|
od_clientpool_total(od_clientpool_t *pool) {
|
||||||
return pool->count_active + pool->count_queue;
|
return pool->count_active + pool->count_queue +
|
||||||
|
pool->count_pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue