Commit cfc20dd5 authored by unknown's avatar unknown

Updated comments


mysys/queues.c:
  Comments for new functions (no code change)
mysys/thr_alarm.c:
  Updated comment
parent 17d526b7
...@@ -61,6 +61,24 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key, ...@@ -61,6 +61,24 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*
Resize queue
SYNOPSIS
resize_queue()
queue Queue
max_elements New max size for queue
NOTES
If you resize queue to be less than the elements you have in it,
the extra elements will be deleted
RETURN
0 ok
1 Error. In this case the queue is unchanged
*/
int resize_queue(QUEUE *queue, uint max_elements) int resize_queue(QUEUE *queue, uint max_elements)
{ {
byte **new_root; byte **new_root;
...@@ -68,14 +86,16 @@ int resize_queue(QUEUE *queue, uint max_elements) ...@@ -68,14 +86,16 @@ int resize_queue(QUEUE *queue, uint max_elements)
if (queue->max_elements == max_elements) if (queue->max_elements == max_elements)
DBUG_RETURN(0); DBUG_RETURN(0);
if ((new_root= (byte **) my_realloc((void *)queue->root, if ((new_root= (byte **) my_realloc((void *)queue->root,
(max_elements+1)*sizeof(void*), MYF(MY_WME))) == 0) (max_elements+1)*sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1); DBUG_RETURN(1);
set_if_smaller(queue->elements, max_elements); set_if_smaller(queue->elements, max_elements);
queue->max_elements=max_elements; queue->max_elements= max_elements;
queue->root=new_root; queue->root= new_root;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void delete_queue(QUEUE *queue) void delete_queue(QUEUE *queue)
{ {
DBUG_ENTER("delete_queue"); DBUG_ENTER("delete_queue");
......
...@@ -120,16 +120,20 @@ void init_thr_alarm(uint max_alarms) ...@@ -120,16 +120,20 @@ void init_thr_alarm(uint max_alarms)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void resize_thr_alarm(uint max_alarms) void resize_thr_alarm(uint max_alarms)
{ {
pthread_mutex_lock(&LOCK_alarm); pthread_mutex_lock(&LOCK_alarm);
/* it's ok not to shrink the queue sometimes */ /*
It's ok not to shrink the queue as there may be more pending alarms than
than max_alarms
*/
if (alarm_queue.elements < max_alarms) if (alarm_queue.elements < max_alarms)
resize_queue(&alarm_queue,max_alarms+1); resize_queue(&alarm_queue,max_alarms+1);
pthread_mutex_unlock(&LOCK_alarm); pthread_mutex_unlock(&LOCK_alarm);
return;
} }
/* /*
Request alarm after sec seconds. Request alarm after sec seconds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment