Fennel: AioLinuxScheduler Class Reference (original) (raw)
AioLinuxScheduler implements DeviceAccessScheduler via Linux-specific kernel-mode libaio calls. More...
#include <[AioLinuxScheduler.h](AioLinuxScheduler%5F8h-source.html)>
Inheritance diagram for AioLinuxScheduler:

| Public Member Functions | |
|---|---|
| AioLinuxScheduler (DeviceAccessSchedulerParams const &) | |
| Constructor. | |
| virtual | ~AioLinuxScheduler () |
| Destructor: stop must already have been called. | |
| virtual void | registerDevice (SharedRandomAccessDevice pDevice) |
| Registers a device for which this scheduler will process requests. | |
| virtual bool | schedule (RandomAccessRequest &request) |
| Initiates a request, the details of which must already have been defined by the caller. | |
| virtual void | stop () |
| Shuts down, waiting for all pending requests to complete. | |
| virtual void | run () |
| virtual void | unregisterDevice (SharedRandomAccessDevice pDevice) |
| Unregisters a device. | |
| virtual void | start () |
| Spawns the OS thread. | |
| void | join () |
| Waits for the OS thread to terminate. | |
| bool | isStopped () const |
| **Returns:**opposite of isStarted() | |
| boost::thread & | getBoostThread () |
| Accesses the underlying boost::thread, e.g. | |
| std::string | getName () |
| void | setName (std::string const &s) |
| Static Public Member Functions | |
| static DeviceAccessScheduler * | newScheduler (DeviceAccessSchedulerParams const ¶ms) |
| Creates a scheduler. | |
| Protected Member Functions | |
| void | initAndRun () |
| virtual void | beforeRun () |
| virtual void | afterRun () |
| Protected Attributes | |
| boost::thread * | pBoostThread |
| bool | bRunning |
| std::string | name |
| Private Member Functions | |
| bool | isStarted () const |
| **Returns:**true if start has been called (and subsequent join has not completed) | |
| bool | submitRequests (RandomAccessRequest::BindingList &bindingList) |
| Submits a list of requests which have already been fully prepared. | |
| void | deferLeftoverRequests (iocb **ppLeftovers, uint nLeftovers) |
| Saves failed requests to the deferred queue for retry. | |
| bool | retryDeferredRequests () |
| Retries submission of requests from the deferred queue; continues until either a submission attempt fails or the queue is exhausted. | |
| Private Attributes | |
| io_context_t | context |
| Context for calling libaio. | |
| AtomicCounter | nRequestsOutstanding |
| Number of requests for which io_submit has been called and a corresponding io_getevents notification has not yet been processed. | |
| bool | quit |
| Flag for passively asking the scheduler to shut down. | |
| std::deque< RandomAccessRequest::BindingList > | deferredQueue |
| FIFO queue of requests which have been deferred due to not-fully-successful io_submit calls. | |
| StrictMutex | deferredQueueMutex |
| Mutex used to protect deferredQueue. |
Detailed Description
AioLinuxScheduler implements DeviceAccessScheduler via Linux-specific kernel-mode libaio calls.
Version:
Id
//open/dev/fennel/device/AioLinuxScheduler.h#7
Definition at line 46 of file AioLinuxScheduler.h.
Constructor & Destructor Documentation
| AioLinuxScheduler::~AioLinuxScheduler | ( | | ) | [virtual] | | -------------------------------------- | - | | - | ----------- |
Member Function Documentation
| bool AioLinuxScheduler::isStarted | ( | | ) | const [inline, private] | | --------------------------------- | - | | - | ------------------------- |
| void AioLinuxScheduler::deferLeftoverRequests | ( | iocb ** | ppLeftovers, |
|---|---|---|---|
| uint | nLeftovers | ||
| ) | [private] |
| bool AioLinuxScheduler::retryDeferredRequests | ( | | ) | [private] | | --------------------------------------------- | - | | - | ----------- |
Retries submission of requests from the deferred queue; continues until either a submission attempt fails or the queue is exhausted.
Returns:
whether all deferred requests were successfully submitted (returns true if there were no deferred requests to begin with)
Definition at line 160 of file AioLinuxScheduler.cpp.
References deferredQueue, deferredQueueMutex, and submitRequests().
Referenced by run().
Registers a device for which this scheduler will process requests.
The default implementation does nothing.
Parameters:
| pDevice | device to be registered |
|---|
Reimplemented from DeviceAccessScheduler.
Definition at line 73 of file AioLinuxScheduler.cpp.
00075 {
00076 int hFile = pDevice->getHandle();
00077
00078
00079
00080 int flags = fcntl(hFile, F_GETFL);
00081 fcntl(hFile, F_SETFL, flags | O_DIRECT);
00082 }
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 84 of file AioLinuxScheduler.cpp.
References RandomAccessRequest::bindingList, isStarted(), RandomAccessRequest::pDevice, RandomAccessDevice::prepareTransfer(), and submitRequests().
| void AioLinuxScheduler::stop | ( | | ) | [virtual] | | ---------------------------- | - | | - | ----------- |
| void AioLinuxScheduler::run | ( | | ) | [virtual] | | --------------------------- | - | | - | ----------- |
| void Thread::initAndRun | ( | | ) | [protected, inherited] | | ----------------------- | - | | - | ------------------------ |
| void Thread::beforeRun | ( | | ) | [protected, virtual, inherited] | | ---------------------- | - | | - | --------------------------------- |
| void Thread::afterRun | ( | | ) | [protected, virtual, inherited] | | --------------------- | - | | - | --------------------------------- |
| void Thread::start | ( | | ) | [virtual, inherited] | | ------------------ | - | | - | ---------------------- |
| void Thread::join | ( | | ) | [inherited] | | ----------------- | - | | - | ------------- |
| bool Thread::isStopped | ( | | ) | const [inline, inherited] | | ---------------------- | - | | - | --------------------------- |
| boost::thread& Thread::getBoostThread | ( | | ) | [inline, inherited] | | ------------------------------------- | - | | - | --------------------- |
Accesses the underlying boost::thread, e.g.
for use in a boost::thread_group. This thread must already be started.
Returns:
the underlying boost::thread
Definition at line 90 of file Thread.h.
| std::string Thread::getName | ( | | ) | [inline, inherited] | | --------------------------- | - | | - | --------------------- |
Definition at line 96 of file Thread.h.
00097 { 00098 return name; 00099 }
| void Thread::setName | ( | std::string const & | s | ) | [inline, inherited] |
|---|
Member Data Documentation
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/device/AioLinuxScheduler.h
- /home/pub/open/dev/fennel/device/AioLinuxScheduler.cpp
