ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.h
(Generate patch)

Comparing libeio/eio.h (file contents):
Revision 1.28 by root, Fri Feb 11 00:53:24 2011 UTC vs.
Revision 1.36 by sf-exg, Thu Jul 7 17:35:52 2011 UTC

43#ifdef __cplusplus 43#ifdef __cplusplus
44extern "C" { 44extern "C" {
45#endif 45#endif
46 46
47#include <stddef.h> 47#include <stddef.h>
48#include <signal.h>
48#include <sys/types.h> 49#include <sys/types.h>
49 50
50typedef struct eio_req eio_req; 51typedef struct eio_req eio_req;
51typedef struct eio_dirent eio_dirent; 52typedef struct eio_dirent eio_dirent;
52 53
152 EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, 153 EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC,
153 EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE, 154 EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE,
154 EIO_MLOCK, EIO_MLOCKALL, 155 EIO_MLOCK, EIO_MLOCKALL,
155 EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, 156 EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME,
156 EIO_MKNOD, EIO_READDIR, 157 EIO_MKNOD, EIO_READDIR,
157 EIO_LINK, EIO_SYMLINK, EIO_READLINK, 158 EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH,
158 EIO_GROUP, EIO_NOP, 159 EIO_GROUP, EIO_NOP,
159 EIO_BUSY 160 EIO_BUSY
160}; 161};
161 162
162/* mlockall constants */ 163/* mlockall constants */
193 int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */ 194 int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
194 long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range: flags */ 195 long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range: flags */
195 long int3; /* chown, fchown: gid */ 196 long int3; /* chown, fchown: gid */
196 int errorno; /* errno value on syscall return */ 197 int errorno; /* errno value on syscall return */
197 198
199#if __i386 || __amd64
200 unsigned char cancelled;
201#else
202 sig_atomic_t cancelled;
203#endif
204
198 unsigned char flags; /* private */ 205 unsigned char flags; /* private */
199 signed char pri; /* the priority */ 206 signed char pri; /* the priority */
200 207
201 void *data; 208 void *data;
202 eio_cb finish; 209 eio_cb finish;
203 void (*destroy)(eio_req *req); /* called when requets no longer needed */ 210 void (*destroy)(eio_req *req); /* called when request no longer needed */
204 void (*feed)(eio_req *req); /* only used for group requests */ 211 void (*feed)(eio_req *req); /* only used for group requests */
205 212
206 EIO_REQ_MEMBERS 213 EIO_REQ_MEMBERS
207 214
208 eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */ 215 eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */
209}; 216};
210 217
211/* _private_ request flags */ 218/* _private_ request flags */
212enum { 219enum {
213 EIO_FLAG_CANCELLED = 0x01, /* request was cancelled */
214 EIO_FLAG_PTR1_FREE = 0x02, /* need to free(ptr1) */ 220 EIO_FLAG_PTR1_FREE = 0x01, /* need to free(ptr1) */
215 EIO_FLAG_PTR2_FREE = 0x04, /* need to free(ptr2) */ 221 EIO_FLAG_PTR2_FREE = 0x02, /* need to free(ptr2) */
216 EIO_FLAG_GROUPADD = 0x08 /* some request was added to the group */ 222 EIO_FLAG_GROUPADD = 0x04 /* some request was added to the group */
217}; 223};
218 224
219/* undocumented/unsupported/private helper */ 225/* undocumented/unsupported/private helper */
220/*void eio_page_align (void **addr, size_t *length);*/ 226/*void eio_page_align (void **addr, size_t *length);*/
221 227
239 * maximum wanted number 245 * maximum wanted number
240 * or maximum idle number of threads */ 246 * or maximum idle number of threads */
241void eio_set_min_parallel (unsigned int nthreads); 247void eio_set_min_parallel (unsigned int nthreads);
242void eio_set_max_parallel (unsigned int nthreads); 248void eio_set_max_parallel (unsigned int nthreads);
243void eio_set_max_idle (unsigned int nthreads); 249void eio_set_max_idle (unsigned int nthreads);
250void eio_set_idle_timeout (unsigned int seconds);
244 251
245unsigned int eio_nreqs (void); /* number of requests in-flight */ 252unsigned int eio_nreqs (void); /* number of requests in-flight */
246unsigned int eio_nready (void); /* number of not-yet handled requests */ 253unsigned int eio_nready (void); /* number of not-yet handled requests */
247unsigned int eio_npending (void); /* numbe rof finished but unhandled requests */ 254unsigned int eio_npending (void); /* number of finished but unhandled requests */
248unsigned int eio_nthreads (void); /* number of worker threads in use currently */ 255unsigned int eio_nthreads (void); /* number of worker threads in use currently */
249 256
250/*****************************************************************************/ 257/*****************************************************************************/
251/* convinience wrappers */ 258/* convenience wrappers */
252 259
253#ifndef EIO_NO_WRAPPERS 260#ifndef EIO_NO_WRAPPERS
254eio_req *eio_nop (int pri, eio_cb cb, void *data); /* does nothing except go through the whole process */ 261eio_req *eio_nop (int pri, eio_cb cb, void *data); /* does nothing except go through the whole process */
255eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data); /* ties a thread for this long, simulating busyness */ 262eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data); /* ties a thread for this long, simulating busyness */
256eio_req *eio_sync (int pri, eio_cb cb, void *data); 263eio_req *eio_sync (int pri, eio_cb cb, void *data);
281eio_req *eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data); 288eio_req *eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data);
282eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ 289eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */
283eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data); 290eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data);
284eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data); 291eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data);
285eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ 292eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */
293eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */
286eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ 294eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
287eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ 295eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
288eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ 296eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
289eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data); 297eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data);
290eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data); 298eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
291eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data); 299eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
292eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data); 300eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
293eio_req *eio_custom (eio_cb execute, int pri, eio_cb cb, void *data); 301eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data);
294#endif 302#endif
295 303
296/*****************************************************************************/ 304/*****************************************************************************/
297/* groups */ 305/* groups */
298 306
304 312
305/*****************************************************************************/ 313/*****************************************************************************/
306/* request api */ 314/* request api */
307 315
308/* true if the request was cancelled, useful in the invoke callback */ 316/* true if the request was cancelled, useful in the invoke callback */
309#define EIO_CANCELLED(req) ((req)->flags & EIO_FLAG_CANCELLED) 317#define EIO_CANCELLED(req) ((req)->cancelled)
310 318
311#define EIO_RESULT(req) ((req)->result) 319#define EIO_RESULT(req) ((req)->result)
312/* returns a pointer to the result buffer allocated by eio */ 320/* returns a pointer to the result buffer allocated by eio */
313#define EIO_BUF(req) ((req)->ptr2) 321#define EIO_BUF(req) ((req)->ptr2)
314#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req)) 322#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req))
317 325
318/* submit a request for execution */ 326/* submit a request for execution */
319void eio_submit (eio_req *req); 327void eio_submit (eio_req *req);
320/* cancel a request as soon fast as possible, if possible */ 328/* cancel a request as soon fast as possible, if possible */
321void eio_cancel (eio_req *req); 329void eio_cancel (eio_req *req);
322/* destroy a request that has never been submitted */
323void eio_destroy (eio_req *req);
324 330
325/*****************************************************************************/ 331/*****************************************************************************/
326/* convinience functions */ 332/* convenience functions */
327 333
328ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count); 334ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count);
329 335
330#ifdef __cplusplus 336#ifdef __cplusplus
331} 337}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines