~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/os0sync.h

  • Committer: Brian Aker
  • Date: 2010-10-15 05:30:39 UTC
  • mfrom: (1843.8.7 trunk-drizzle)
  • Revision ID: brian@tangent.org-20101015053039-ebmv3hnn1yaq4wqy
Merge in refactoring on table (broken it up by type, this will allow me to
insert the new locking).

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "ut0lst.h"
39
39
 
40
40
#ifdef __WIN__
41
 
/** Native event (slow)*/
42
 
typedef HANDLE                  os_native_event_t;
 
41
 
43
42
/** Native mutex */
44
 
typedef CRITICAL_SECTION        os_fast_mutex_t;
45
 
/** Native condition variable. */
46
 
typedef CONDITION_VARIABLE      os_cond_t;
 
43
#define os_fast_mutex_t CRITICAL_SECTION
 
44
 
 
45
/** Native event */
 
46
typedef HANDLE          os_native_event_t;
 
47
 
 
48
/** Operating system event */
 
49
typedef struct os_event_struct  os_event_struct_t;
 
50
/** Operating system event handle */
 
51
typedef os_event_struct_t*      os_event_t;
 
52
 
 
53
/** An asynchronous signal sent between threads */
 
54
struct os_event_struct {
 
55
        os_native_event_t                 handle;
 
56
                                        /*!< Windows event */
 
57
        UT_LIST_NODE_T(os_event_struct_t) os_event_list;
 
58
                                        /*!< list of all created events */
 
59
};
47
60
#else
48
61
/** Native mutex */
49
 
typedef pthread_mutex_t         os_fast_mutex_t;
50
 
/** Native condition variable */
51
 
typedef pthread_cond_t          os_cond_t;
52
 
#endif
 
62
typedef pthread_mutex_t os_fast_mutex_t;
53
63
 
54
64
/** Operating system event */
55
65
typedef struct os_event_struct  os_event_struct_t;
58
68
 
59
69
/** An asynchronous signal sent between threads */
60
70
struct os_event_struct {
61
 
#ifdef __WIN__
62
 
        HANDLE          handle;         /*!< kernel event object, slow,
63
 
                                        used on older Windows */
64
 
#endif
65
71
        os_fast_mutex_t os_mutex;       /*!< this mutex protects the next
66
72
                                        fields */
67
73
        ibool           is_set;         /*!< this is TRUE when the event is
70
76
                                        this event */
71
77
        ib_int64_t      signal_count;   /*!< this is incremented each time
72
78
                                        the event becomes signaled */
73
 
        os_cond_t       cond_var;       /*!< condition variable is used in
 
79
        pthread_cond_t  cond_var;       /*!< condition variable is used in
74
80
                                        waiting for the event */
75
81
        UT_LIST_NODE_T(os_event_struct_t) os_event_list;
76
82
                                        /*!< list of all created events */
77
83
};
 
84
#endif
78
85
 
79
86
/** Operating system mutex */
80
87
typedef struct os_mutex_struct  os_mutex_str_t;
81
88
/** Operating system mutex handle */
82
89
typedef os_mutex_str_t*         os_mutex_t;
83
90
 
 
91
/** Denotes an infinite delay for os_event_wait_time() */
 
92
#define OS_SYNC_INFINITE_TIME   ((ulint)(-1))
 
93
 
 
94
/** Return value of os_event_wait_time() when the time is exceeded */
 
95
#define OS_SYNC_TIME_EXCEEDED   1
 
96
 
84
97
/** Mutex protecting counts and the event and OS 'slow' mutex lists */
85
98
extern os_mutex_t       os_sync_mutex;
86
99
 
174
187
 
175
188
#define os_event_wait(event) os_event_wait_low(event, 0)
176
189
 
 
190
/**********************************************************//**
 
191
Waits for an event object until it is in the signaled state or
 
192
a timeout is exceeded. In Unix the timeout is always infinite.
 
193
@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
 
194
UNIV_INTERN
 
195
ulint
 
196
os_event_wait_time(
 
197
/*===============*/
 
198
        os_event_t      event,  /*!< in: event to wait */
 
199
        ulint           time);  /*!< in: timeout in microseconds, or
 
200
                                OS_SYNC_INFINITE_TIME */
 
201
#ifdef __WIN__
 
202
/**********************************************************//**
 
203
Waits for any event in an OS native event array. Returns if even a single
 
204
one is signaled or becomes signaled.
 
205
@return index of the event which was signaled */
 
206
UNIV_INTERN
 
207
ulint
 
208
os_event_wait_multiple(
 
209
/*===================*/
 
210
        ulint                   n,      /*!< in: number of events in the
 
211
                                        array */
 
212
        os_native_event_t*      native_event_array);
 
213
                                        /*!< in: pointer to an array of event
 
214
                                        handles */
 
215
#endif
177
216
/*********************************************************//**
178
217
Creates an operating system mutex semaphore. Because these are slow, the
179
218
mutex semaphore of InnoDB itself (mutex_t) should be used where possible.
180
219
@return the mutex handle */
181
220
UNIV_INTERN
182
221
os_mutex_t
183
 
os_mutex_create(void);
184
 
/*=================*/
 
222
os_mutex_create(
 
223
/*============*/
 
224
        const char*     name);  /*!< in: the name of the mutex, if NULL
 
225
                                the mutex is created without a name */
185
226
/**********************************************************//**
186
227
Acquires ownership of a mutex semaphore. */
187
228
UNIV_INTERN
289
330
Returns the old value of *ptr, atomically sets *ptr to new_val */
290
331
 
291
332
# define os_atomic_test_and_set_byte(ptr, new_val) \
292
 
        __sync_lock_test_and_set(ptr, (byte) new_val)
 
333
        __sync_lock_test_and_set(ptr, new_val)
293
334
 
294
335
#elif defined(HAVE_SOLARIS_ATOMICS)
295
336