DeviceAccessScheduler Class Reference

DeviceAccessScheduler is an interface representing the ability to initiate access requests on devices and handle their completions asynchronously. More...

#include <DeviceAccessScheduler.h>

Inheritance diagram for DeviceAccessScheduler:

AioLinuxScheduler AioPollingScheduler AioSignalScheduler IoCompletionPortScheduler ThreadPoolScheduler List of all members.

Public Member Functions

virtual ~DeviceAccessScheduler ()
virtual void registerDevice (SharedRandomAccessDevice pDevice)
 Registers a device for which this scheduler will process requests.
virtual void unregisterDevice (SharedRandomAccessDevice pDevice)
 Unregisters a device.
virtual bool schedule (RandomAccessRequest &request)=0
 Initiates a request, the details of which must already have been defined by the caller.
virtual void stop ()=0
 Shuts down, waiting for all pending requests to complete.

Static Public Member Functions

static DeviceAccessSchedulernewScheduler (DeviceAccessSchedulerParams const &params)
 Creates a scheduler.

Detailed Description

DeviceAccessScheduler is an interface representing the ability to initiate access requests on devices and handle their completions asynchronously.

For more information, see DeviceDesign.

Definition at line 37 of file DeviceAccessScheduler.h.


Constructor & Destructor Documentation

DeviceAccessScheduler::~DeviceAccessScheduler (  )  [virtual]

Definition at line 115 of file DeviceAccessScheduler.cpp.

00116 {
00117 }


Member Function Documentation

DeviceAccessScheduler * DeviceAccessScheduler::newScheduler ( DeviceAccessSchedulerParams const &  params  )  [static]

Creates a scheduler.

Parameters:
params DeviceAccessSchedulerParams to use
Returns:
new scheduler; caller is responsible for deleting it

Definition at line 70 of file DeviceAccessScheduler.cpp.

References DeviceAccessSchedulerParams::AIO_LINUX_SCHEDULER, DeviceAccessSchedulerParams::AIO_POLLING_SCHEDULER, DeviceAccessSchedulerParams::AIO_SIGNAL_SCHEDULER, dlopenAioLinuxScheduler(), DeviceAccessSchedulerParams::IO_COMPLETION_PORT_SCHEDULER, DeviceAccessSchedulerParams::schedulerType, DeviceAccessSchedulerParams::THREAD_POOL_SCHEDULER, and DeviceAccessSchedulerParams::usingDefaultSchedulerType.

Referenced by CacheImpl< PageT, VictimPolicyT >::CacheImpl(), and RandomAccessFileDeviceTest::testAsyncIOImpl().

00072 {
00073     switch (params.schedulerType) {
00074     case DeviceAccessSchedulerParams::THREAD_POOL_SCHEDULER:
00075         return new ThreadPoolScheduler(params);
00076 
00077 #ifdef __MSVC__
00078     case DeviceAccessSchedulerParams::IO_COMPLETION_PORT_SCHEDULER:
00079         return new IoCompletionPortScheduler(params);
00080 #endif
00081 
00082 #ifdef USE_LIBAIO_H
00083     case DeviceAccessSchedulerParams::AIO_LINUX_SCHEDULER:
00084         {
00085             DeviceAccessScheduler *pScheduler = dlopenAioLinuxScheduler(params);
00086             if (pScheduler) {
00087                 return pScheduler;
00088             } else {
00089                 // if the aioLinux scheduler was explicitly selected (vs simply
00090                 // using the default type for the OS), then the AIO runtime
00091                 // library must be installed; otherwise, fall through to use
00092                 // ThreadPoolScheduler as fallback
00093                 if (params.usingDefaultSchedulerType) {
00094                     break;
00095                 }
00096                 throw FennelExcn(FennelResource::instance().libaioRequired());
00097             }
00098         }
00099 #endif
00100 
00101 #ifdef USE_AIO_H
00102     case DeviceAccessSchedulerParams::AIO_POLLING_SCHEDULER:
00103         return new AioPollingScheduler(params);
00104     case DeviceAccessSchedulerParams::AIO_SIGNAL_SCHEDULER:
00105         return new AioSignalScheduler(params);
00106 #endif
00107 
00108     default:
00109         // fall through to use ThreadPoolScheduler as a fallback
00110         break;
00111     }
00112     return new ThreadPoolScheduler(params);
00113 }

void DeviceAccessScheduler::registerDevice ( SharedRandomAccessDevice  pDevice  )  [virtual]

Registers a device for which this scheduler will process requests.

The default implementation does nothing.

Parameters:
pDevice device to be registered

Reimplemented in AioLinuxScheduler, and IoCompletionPortScheduler.

Definition at line 142 of file DeviceAccessScheduler.cpp.

Referenced by RandomAccessFileDeviceTest::testAsyncIOImpl().

00144 {
00145 }

void DeviceAccessScheduler::unregisterDevice ( SharedRandomAccessDevice  pDevice  )  [virtual]

Unregisters a device.

The default implementation does nothing.

Parameters:
pDevice device to be unregistered

Definition at line 147 of file DeviceAccessScheduler.cpp.

Referenced by RandomAccessFileDeviceTest::testAsyncIOImpl().

00149 {
00150 }

virtual bool DeviceAccessScheduler::schedule ( RandomAccessRequest request  )  [pure virtual]

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

Implemented in AioLinuxScheduler, AioPollingScheduler, AioSignalScheduler, IoCompletionPortScheduler, and ThreadPoolScheduler.

Referenced by SegPageBackupRestoreDevice::backupPage(), CacheImpl< PageT, VictimPolicyT >::prefetchBatch(), SegPageBackupRestoreDevice::restorePage(), and RandomAccessFileDeviceTest::testAsyncIOImpl().

virtual void DeviceAccessScheduler::stop (  )  [pure virtual]

Shuts down, waiting for all pending requests to complete.

Implemented in AioLinuxScheduler, AioPollingScheduler, AioSignalScheduler, IoCompletionPortScheduler, and ThreadPoolScheduler.

Referenced by CacheImpl< PageT, VictimPolicyT >::closeImpl(), and RandomAccessFileDeviceTest::testAsyncIOImpl().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:29 2009 for Fennel by  doxygen 1.5.1