~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/internal/iocache.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
struct st_io_cache;
32
32
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
33
33
 
34
 
typedef struct st_io_cache_share
35
 
{
36
 
  pthread_mutex_t       mutex;           /* To sync on reads into buffer. */
37
 
  pthread_cond_t        cond;            /* To wait for signals. */
38
 
  pthread_cond_t        cond_writer;     /* For a synchronized writer. */
39
 
  /* Offset in file corresponding to the first byte of buffer. */
40
 
  my_off_t              pos_in_file;
41
 
  /* If a synchronized write cache is the source of the data. */
42
 
  struct st_io_cache    *source_cache;
43
 
  unsigned char                 *buffer;         /* The read buffer. */
44
 
  unsigned char                 *read_end;       /* Behind last valid byte of buffer. */
45
 
  int                   running_threads; /* threads not in lock. */
46
 
  int                   total_threads;   /* threads sharing the cache. */
47
 
  int                   error;           /* Last error. */
48
 
} IO_CACHE_SHARE;
49
 
 
50
 
typedef struct st_io_cache    /* Used when cacheing files */
 
34
struct st_io_cache    /* Used when cacheing files */
51
35
{
52
36
  /* Offset in file corresponding to the first byte of unsigned char* buffer. */
53
37
  my_off_t pos_in_file;
87
71
  */
88
72
  unsigned char  **current_pos, **current_end;
89
73
  /*
90
 
    The lock is for append buffer used in SEQ_READ_APPEND cache
91
 
    need mutex copying from append buffer to read buffer.
92
 
  */
93
 
  pthread_mutex_t append_buffer_lock;
94
 
  /*
95
 
    The following is used when several threads are reading the
96
 
    same file in parallel. They are synchronized on disk
97
 
    accesses reading the cached part of the file asynchronously.
98
 
    It should be set to NULL to disable the feature.  Only
99
 
    READ_CACHE mode is supported.
100
 
  */
101
 
  IO_CACHE_SHARE *share;
102
 
  /*
103
74
    A caller will use my_b_read() macro to read from the cache
104
75
    if the data is already in cache, it will be simply copied with
105
76
    memcpy() and internal variables will be accordinging updated with
163
134
  my_off_t aio_read_pos;
164
135
  my_aio_result aio_result;
165
136
#endif
166
 
} IO_CACHE;
 
137
 
 
138
  st_io_cache() :
 
139
    pos_in_file(0),
 
140
    end_of_file(0),
 
141
    read_pos(0),
 
142
    read_end(0),
 
143
    buffer(0),
 
144
    request_pos(0),
 
145
    write_buffer(0),
 
146
    append_read_pos(0),
 
147
    write_pos(0),
 
148
    write_end(0),
 
149
    current_pos(0),
 
150
    current_end(0),
 
151
    read_function(0),
 
152
    write_function(0),
 
153
    type(TYPE_NOT_SET),
 
154
    error(0),
 
155
    pre_read(0),
 
156
    post_read(0),
 
157
    pre_close(0),
 
158
    arg(0),
 
159
    file_name(0),
 
160
    dir(0),
 
161
    prefix(0),
 
162
    file(0),
 
163
    seek_not_done(0),
 
164
    buffer_length(0),
 
165
    read_length(0),
 
166
    myflags(0),
 
167
    alloced_buffer(0)
 
168
#ifdef HAVE_AIOWAIT
 
169
    ,
 
170
    inited(0),
 
171
    aio_read_pos(0),
 
172
    aio_result(0)
 
173
#endif
 
174
  { }
 
175
 
 
176
  ~st_io_cache()
 
177
  { }
 
178
};
 
179
 
 
180
typedef struct st_io_cache IO_CACHE;    /* Used when cacheing files */
167
181
 
168
182
extern int init_io_cache(IO_CACHE *info,int file,size_t cachesize,
169
183
                         enum cache_type type,my_off_t seek_offset,
172
186
                            my_off_t seek_offset,bool use_async_io,
173
187
                            bool clear_cache);
174
188
extern void setup_io_cache(IO_CACHE* info);
175
 
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
176
 
                                IO_CACHE *write_cache, uint32_t num_threads);
177
 
extern void remove_io_thread(IO_CACHE *info);
178
189
extern int _my_b_get(IO_CACHE *info);
179
190
extern int _my_b_async_read(IO_CACHE *info,unsigned char *Buffer,size_t Count);
180
191