28AIODiskIOStrategy::AIODiskIOStrategy() :
31 aq.aq_state = AQ_STATE_NONE;
33 memset(&aq.aq_queue, 0,
sizeof(aq.aq_queue));
36AIODiskIOStrategy::~AIODiskIOStrategy()
38 assert(aq.aq_state == AQ_STATE_SETUP ||
39 aq.aq_numpending == 0);
42 aq.aq_state = AQ_STATE_NONE;
46AIODiskIOStrategy::shedLoad()
52AIODiskIOStrategy::load()
54 return aq.aq_numpending * 1000 / MAX_ASYNCOP;
58AIODiskIOStrategy::newFile (
char const *path)
64 return new AIODiskFile (path,
this);
68AIODiskIOStrategy::sync()
70 assert(aq.aq_state == AQ_STATE_SETUP);
78 while (aq.aq_numpending)
83AIODiskIOStrategy::unlinkdUseful()
const
89AIODiskIOStrategy::unlinkFile (
char const *)
101AIODiskIOStrategy::callback()
111 async_queue_entry_t *aqe;
112 async_queue_entry_type_t type;
114 assert(aq.aq_state == AQ_STATE_SETUP);
118 for (i = 0; i < MAX_ASYNCOP; ++i) {
119 if (aq.aq_queue[i].aq_e_state == AQ_ENTRY_USED) {
120 aqe = &aq.aq_queue[i];
122 reterr = aio_error(&aqe->aq_e_aiocb);
125 fatal(
"aio_error returned an error!\n");
128 if (reterr != EINPROGRESS) {
130 retval = aio_return(&aqe->aq_e_aiocb);
133 freefunc = aqe->aq_e_free;
135 type = aqe->aq_e_type;
137 AIODiskFile * theFile =
nullptr;
138 void *theFileVoid =
nullptr;
139 void *theTmpFile = aqe->theFile;
143 theFile =
static_cast<AIODiskFile *
>(theFileVoid);
147 memset(aqe, 0,
sizeof(async_queue_entry_t));
149 aqe->aq_e_state = AQ_ENTRY_FREE;
155 if (callback_valid) {
158 if (type == AQ_ENTRY_READ)
159 theFile->ioRequestor->readCompleted((
const char *)buf, retval, reterr,
static_cast<ReadRequest *
>(
cbdata));
161 if (type == AQ_ENTRY_WRITE)
162 theFile->ioRequestor->writeCompleted(reterr,retval,
static_cast<WriteRequest *
>(
cbdata));
165 if (type == AQ_ENTRY_WRITE && freefunc)
176AIODiskIOStrategy::init()
179 assert(aq.aq_state == AQ_STATE_NONE);
184 aq.aq_state = AQ_STATE_SETUP;
192AIODiskIOStrategy::getOptionTree()
const
202AIODiskIOStrategy::findSlot()
206 for (
int i = 0; i < MAX_ASYNCOP; ++i) {
207 if (aq.aq_queue[i].aq_e_state == AQ_ENTRY_FREE)
#define cbdataReferenceValidDone(var, ptr)
void fatal(const char *message)