xrootd
XrdSfsAio.hh
Go to the documentation of this file.
1 #ifndef __SFS_AIO_H__
2 #define __SFS_AIO_H__
3 /******************************************************************************/
4 /* */
5 /* X r d S f s A i o . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include <signal.h>
16 #include <sys/types.h>
17 #ifdef _POSIX_ASYNCHRONOUS_IO
18 #ifdef __macos__
19 #include <AvailabilityMacros.h>
20 #include <sys/aio.h>
21 #else
22 #include <aio.h>
23 #endif
24 #else
25 struct aiocb { // Minimal structure to avoid compiler errors
27  void *aio_buf;
28  size_t aio_nbytes;
29  off_t aio_offset;
31  struct sigevent aio_sigevent;
32  };
33 #endif
34 
35 // The XrdSfsAIO class is meant to be derived. This object provides the
36 // basic interface to handle AIO control block queues not processing.
37 //
38 class XrdSfsAio
39 {
40 public:
41 
42 struct aiocb sfsAio;
43 
44 ssize_t Result; // If >= 0 valid result; else is -errno
45 
46 const char *TIdent; // Trace information (optional)
47 
48 // Method to handle completed reads
49 //
50 virtual void doneRead() = 0;
51 
52 // Method to hand completed writes
53 //
54 virtual void doneWrite() = 0;
55 
56 // Method to recycle free object
57 //
58 virtual void Recycle() = 0;
59 
61 #if defined(__macos__) && (!defined(MAC_OS_X_VERSION_10_4) || \
62  MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4)
63  sfsAio.aio_sigevent.sigev_value.sigval_ptr = (void *)this;
64 #else
65  sfsAio.aio_sigevent.sigev_value.sival_ptr = (void *)this;
66 #endif
67  sfsAio.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
68  sfsAio.aio_reqprio = 0;
69  TIdent = (char *)"";
70  }
71 virtual ~XrdSfsAio() {}
72 };
73 #endif