AtlasDeferredFile Class Reference [Atlas Core]

#include <atlasDeferredFile.h>

List of all members.


Detailed Description

Basic background IO implementation for Atlas files.

This class is responsible for executing requests described by AtlasDeferredIO structures.

It also provides a mechanism for acquiring the file's stream exclusively, and allowing other code to do IO on that stream, without disturbing the deferred IO tasks.


Public Member Functions

 AtlasDeferredFile ()
 ~AtlasDeferredFile ()
bool initStream (const char *filename, U32 mode)
 Initialize access to a specified file, with the appropriate IO mode.
void start ()
 Start the deferred IO thread.
void stop ()
 Stop the deferred IO thread.
void sync ()
 Synch with the deferred IO thread and do appropriate callbacks for any finished IO operations, as described in the AtlasDeferredIO class.
void queue (AtlasDeferredIO *io)
 Queue an ADIO.
void ensureStreamWritable ()
 Make sure that we have acquired ability to write to stream.
StreamlockStream (bool needWrite=false)
 Get the file stream for exclusive access. Don't forget to call unlockStream()!
void unlockStream ()
 Unlock the stream after exclusive mode IO is completed.
const bool hasStream () const
 Do we currently have an active stream?
bool isLoading ()
 Return true if we currently have an IO activity going on.
voidgetLoadingMutex ()
bool hasPendingIO ()
 Return true if we have any pending or in-process IO operations.
const U32 getTimeSpentWorking () const
 Return the time in ms that the IO thread has spent working.
const U32 getTimeSpentWaiting () const
 Return the time in ms that the IO thread has spent waiting.
const U32 getLoadOperationsCompleted () const
 Return the number of operation the background thread has completed.

Private Member Functions

void loaderThread ()

Static Private Member Functions

static void loaderThunk (void *a)

Private Attributes

const char * mFilename
voidmStreamMutex
StreammStream
ThreadSafeQueue< AtlasDeferredIO * > mDeferredRequestQueue
ThreadSafeQueue< AtlasDeferredIO * > mDeferredResultQueue
bool mCanWriteStream
voidmLoadingMutex
SemaphoremLoadingSemaphore
ThreadmDeferredLoaderThread
volatile bool mDeferredLoaderThreadActive
volatile U32 mTimeSpentWorking
volatile U32 mTimeSpentWaiting
volatile U32 mLoadOperationsCompleted


Constructor & Destructor Documentation

AtlasDeferredFile::AtlasDeferredFile (  ) 

AtlasDeferredFile::~AtlasDeferredFile (  ) 


Member Function Documentation

static void AtlasDeferredFile::loaderThunk ( void a  )  [static, private]

void AtlasDeferredFile::loaderThread (  )  [private]

bool AtlasDeferredFile::initStream ( const char *  filename,
U32  mode 
)

Initialize access to a specified file, with the appropriate IO mode.

void AtlasDeferredFile::start (  ) 

Start the deferred IO thread.

void AtlasDeferredFile::stop (  ) 

Stop the deferred IO thread.

void AtlasDeferredFile::sync (  ) 

Synch with the deferred IO thread and do appropriate callbacks for any finished IO operations, as described in the AtlasDeferredIO class.

void AtlasDeferredFile::queue ( AtlasDeferredIO io  ) 

Queue an ADIO.

void AtlasDeferredFile::ensureStreamWritable (  ) 

Make sure that we have acquired ability to write to stream.

Stream* AtlasDeferredFile::lockStream ( bool  needWrite = false  )  [inline]

Get the file stream for exclusive access. Don't forget to call unlockStream()!

void AtlasDeferredFile::unlockStream (  )  [inline]

Unlock the stream after exclusive mode IO is completed.

const bool AtlasDeferredFile::hasStream (  )  const [inline]

Do we currently have an active stream?

bool AtlasDeferredFile::isLoading (  )  [inline]

Return true if we currently have an IO activity going on.

void* AtlasDeferredFile::getLoadingMutex (  )  [inline]

bool AtlasDeferredFile::hasPendingIO (  ) 

Return true if we have any pending or in-process IO operations.

const U32 AtlasDeferredFile::getTimeSpentWorking (  )  const [inline]

Return the time in ms that the IO thread has spent working.

const U32 AtlasDeferredFile::getTimeSpentWaiting (  )  const [inline]

Return the time in ms that the IO thread has spent waiting.

const U32 AtlasDeferredFile::getLoadOperationsCompleted (  )  const [inline]

Return the number of operation the background thread has completed.


Member Data Documentation

const char* AtlasDeferredFile::mFilename [private]