AioLinuxScheduler.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/device/AioLinuxScheduler.h#7 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2005-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_AioLinuxScheduler_Included
00024 #define Fennel_AioLinuxScheduler_Included
00025 
00026 #ifdef USE_LIBAIO_H
00027 
00028 #include "fennel/device/DeviceAccessScheduler.h"
00029 #include "fennel/device/RandomAccessRequest.h"
00030 #include "fennel/common/AtomicCounter.h"
00031 #include "fennel/synch/Thread.h"
00032 
00033 #include <vector>
00034 #include <deque>
00035 #include <boost/scoped_array.hpp>
00036 
00037 FENNEL_BEGIN_NAMESPACE
00038 
00046 class FENNEL_DEVICE_EXPORT AioLinuxScheduler
00047     : public DeviceAccessScheduler, public Thread
00048 {
00052     io_context_t context;
00053 
00060     AtomicCounter nRequestsOutstanding;
00061 
00065     bool quit;
00066 
00073     std::deque<RandomAccessRequest::BindingList> deferredQueue;
00074 
00078     StrictMutex deferredQueueMutex;
00079 
00080     inline bool isStarted() const;
00081 
00090     bool submitRequests(RandomAccessRequest::BindingList &bindingList);
00091 
00099     void deferLeftoverRequests(
00100         iocb **ppLeftovers,
00101         uint nLeftovers);
00102 
00111     bool retryDeferredRequests();
00112 
00113 public:
00117     explicit AioLinuxScheduler(DeviceAccessSchedulerParams const &);
00118 
00122     virtual ~AioLinuxScheduler();
00123 
00124 // ----------------------------------------------------------------------
00125 // Implementation of DeviceAccessScheduler interface (q.v.)
00126 // ----------------------------------------------------------------------
00127     virtual void registerDevice(SharedRandomAccessDevice pDevice);
00128     virtual bool schedule(RandomAccessRequest &request);
00129     virtual void stop();
00130 
00131 // ----------------------------------------------------------------------
00132 // Implementation of Thread interface (q.v.)
00133 // ----------------------------------------------------------------------
00134     virtual void run();
00135 };
00136 
00137 FENNEL_END_NAMESPACE
00138 
00139 #endif
00140 
00141 #endif
00142 
00143 // End AioLinuxScheduler.h

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1