export function task_queue_get_new_buffer_size
parent
9c7a510803
commit
12c1355c2a
2
HISTORY
2
HISTORY
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Version 1.24 2016-01-14
|
Version 1.24 2016-01-19
|
||||||
* php extension compiled on PHP 7
|
* php extension compiled on PHP 7
|
||||||
* add skiplist which support stable sort
|
* add skiplist which support stable sort
|
||||||
* make.sh: use sed to replace perl
|
* make.sh: use sed to replace perl
|
||||||
|
|
|
||||||
|
|
@ -629,41 +629,45 @@ int task_queue_count(struct fast_task_queue *pQueue)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _get_new_buffer_size(struct fast_task_queue *pQueue,
|
int task_queue_get_new_buffer_size(const int min_buff_size,
|
||||||
const int expect_size, int *new_size)
|
const int max_buff_size, const int expect_size, int *new_size)
|
||||||
{
|
{
|
||||||
if (pQueue->min_buff_size == pQueue->max_buff_size)
|
if (min_buff_size == max_buff_size)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"can't change buffer size because NOT supported", __LINE__);
|
"can't change buffer size because NOT supported", __LINE__);
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expect_size > pQueue->max_buff_size)
|
if (expect_size > max_buff_size)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"can't change buffer size because expect buffer size: %d "
|
"can't change buffer size because expect buffer size: %d "
|
||||||
"exceeds max buffer size: %d", __LINE__, expect_size,
|
"exceeds max buffer size: %d", __LINE__, expect_size,
|
||||||
pQueue->max_buff_size);
|
max_buff_size);
|
||||||
return EOVERFLOW;
|
return EOVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
*new_size = pQueue->min_buff_size;
|
*new_size = min_buff_size;
|
||||||
if (expect_size > pQueue->min_buff_size)
|
if (expect_size > min_buff_size)
|
||||||
{
|
{
|
||||||
while (*new_size < expect_size)
|
while (*new_size < expect_size)
|
||||||
{
|
{
|
||||||
*new_size *= 2;
|
*new_size *= 2;
|
||||||
}
|
}
|
||||||
if (*new_size > pQueue->max_buff_size)
|
if (*new_size > max_buff_size)
|
||||||
{
|
{
|
||||||
*new_size = pQueue->max_buff_size;
|
*new_size = max_buff_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define _get_new_buffer_size(pQueue, expect_size, new_size) \
|
||||||
|
task_queue_get_new_buffer_size(pQueue->min_buff_size, \
|
||||||
|
pQueue->max_buff_size, expect_size, new_size)
|
||||||
|
|
||||||
int task_queue_set_buffer_size(struct fast_task_queue *pQueue,
|
int task_queue_set_buffer_size(struct fast_task_queue *pQueue,
|
||||||
struct fast_task_info *pTask, const int expect_size)
|
struct fast_task_info *pTask, const int expect_size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,9 @@ int task_queue_set_buffer_size(struct fast_task_queue *pQueue,
|
||||||
int task_queue_realloc_buffer(struct fast_task_queue *pQueue,
|
int task_queue_realloc_buffer(struct fast_task_queue *pQueue,
|
||||||
struct fast_task_info *pTask, const int expect_size);
|
struct fast_task_info *pTask, const int expect_size);
|
||||||
|
|
||||||
|
int task_queue_get_new_buffer_size(const int min_buff_size,
|
||||||
|
const int max_buff_size, const int expect_size, int *new_size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue