Fennel: AioSignalScheduler Class Reference (original) (raw)
Initiates a request, the details of which must already have been defined by the caller.
When the request completes, this scheduler will call notifyTransferCompletion on each binding associated with the request, and also break up the binding list. The bindings must not be altered by the caller until this notification is received. However, the request parameter itself need not live beyond this call.
Care must be taken to ensure that the schedule/notify sequences cannot deadlock. For example, the caller of schedule may hold a lock on a binding, and the implementation of schedule may acquire a scheduler lock internally. The notification callback may also need to take a lock on the binding. Thus, it is important that no scheduler lock be held while notifyTransferCompletion is called.
Parameters:
| request | parameters for the request to be scheduled |
|---|
Returns:
true if the request was successfully scheduled without any retries
Implements DeviceAccessScheduler.
Definition at line 105 of file AioSignalScheduler.cpp.
References RandomAccessRequest::bindingList, IntrusiveListMutator< T, DerivedListNode >::detach(), isStarted(), RandomAccessRequest::pDevice, RandomAccessDevice::prepareTransfer(), RandomAccessRequest::READ, and RandomAccessRequest::type.
00106 {
00107 assert(isStarted());
00108
00109 int rc;
00110
00111
00112
00113 request.pDevice->prepareTransfer(request);
00114 RandomAccessRequest::BindingListMutator bindingMutator(request.bindingList);
00115 while (bindingMutator) {
00116 RandomAccessRequestBinding *pBinding = bindingMutator.detach();
00117 pBinding->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
00118 pBinding->aio_sigevent.sigev_signo = SIGRTMIN;
00119 pBinding->aio_sigevent.sigev_value.sival_ptr = pBinding;
00120
00121
00122
00123
00124 aiocb *lpBinding = static_cast<aiocb *>(pBinding);
00125
00126 if (request.type == RandomAccessRequest::READ) {
00127 rc = aio_read(lpBinding);
00128 } else {
00129 rc = aio_write(lpBinding);
00130 }
00131 assert(!rc);
00132 }
00133
00134 return true;
00135 }