~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/ut/ut0wqueue.c

  • Committer: Brian Aker
  • Date: 2008-12-15 19:32:58 UTC
  • mfrom: (677.1.2 devel)
  • Revision ID: brian@tangent.org-20081215193258-fsvc1sh9h7a9sb1t
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 2006, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
1
#include "ut0wqueue.h"
20
2
 
21
 
/*******************************************************************//**
22
 
@file ut/ut0wqueue.c
23
 
A work queue
24
 
 
25
 
Created 4/26/2006 Osku Salerma
26
 
************************************************************************/
27
 
 
28
 
/****************************************************************//**
29
 
Create a new work queue.
30
 
@return work queue */
 
3
/********************************************************************
 
4
Create a new work queue. */
31
5
UNIV_INTERN
32
6
ib_wqueue_t*
33
7
ib_wqueue_create(void)
34
8
/*===================*/
 
9
                        /* out: work queue */
35
10
{
36
 
        ib_wqueue_t*    wq = static_cast<ib_wqueue_t *>(mem_alloc(sizeof(ib_wqueue_t)));
 
11
        ib_wqueue_t*    wq = mem_alloc(sizeof(ib_wqueue_t));
37
12
 
38
 
        /* Function ib_wqueue_create() has not been used anywhere,
39
 
        not necessary to instrument this mutex */
40
 
        mutex_create(PFS_NOT_INSTRUMENTED, &wq->mutex, SYNC_WORK_QUEUE);
 
13
        mutex_create(&wq->mutex, SYNC_WORK_QUEUE);
41
14
 
42
15
        wq->items = ib_list_create();
43
16
        wq->event = os_event_create(NULL);
45
18
        return(wq);
46
19
}
47
20
 
48
 
/****************************************************************//**
 
21
/********************************************************************
49
22
Free a work queue. */
50
23
UNIV_INTERN
51
24
void
52
25
ib_wqueue_free(
53
26
/*===========*/
54
 
        ib_wqueue_t*    wq)     /*!< in: work queue */
 
27
        ib_wqueue_t*    wq)     /* in: work queue */
55
28
{
56
29
        ut_a(!ib_list_get_first(wq->items));
57
30
 
62
35
        mem_free(wq);
63
36
}
64
37
 
65
 
/****************************************************************//**
 
38
/********************************************************************
66
39
Add a work item to the queue. */
67
40
UNIV_INTERN
68
41
void
69
42
ib_wqueue_add(
70
43
/*==========*/
71
 
        ib_wqueue_t*    wq,     /*!< in: work queue */
72
 
        void*           item,   /*!< in: work item */
73
 
        mem_heap_t*     heap)   /*!< in: memory heap to use for allocating the
 
44
        ib_wqueue_t*    wq,     /* in: work queue */
 
45
        void*           item,   /* in: work item */
 
46
        mem_heap_t*     heap)   /* in: memory heap to use for allocating the
74
47
                                list node */
75
48
{
76
49
        mutex_enter(&wq->mutex);
81
54
        mutex_exit(&wq->mutex);
82
55
}
83
56
 
84
 
/****************************************************************//**
85
 
Wait for a work item to appear in the queue.
86
 
@return work item */
 
57
/********************************************************************
 
58
Wait for a work item to appear in the queue. */
87
59
UNIV_INTERN
88
60
void*
89
61
ib_wqueue_wait(
90
 
/*===========*/
91
 
        ib_wqueue_t*    wq)     /*!< in: work queue */
 
62
                                /* out: work item */
 
63
        ib_wqueue_t*    wq)     /* in: work queue */
92
64
{
93
65
        ib_list_node_t* node;
94
66