LLAPRFile cleaned up

This commit is contained in:
Shyotl
2011-09-20 21:39:27 -05:00
parent 0ace809572
commit d917bf6b06
19 changed files with 126 additions and 215 deletions

View File

@@ -102,12 +102,12 @@ LLAPRFile::LLAPRFile()
{
}
LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type)
LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, S32* sizep, access_t access_type)
: mFile(NULL),
mVolatileFilePoolp(NULL),
mRegularFilePoolp(NULL)
{
open(filename, flags, access_type);
open(filename, flags, access_type, sizep);
}
LLAPRFile::~LLAPRFile()
@@ -147,7 +147,8 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc
apr_status_t status;
{
apr_pool_t* apr_file_open_pool;
if (access_type == local)
// This is a temporary variable for a pool that is passed directly to apr_file_open below.
if (access_type == short_lived)
{
// Use a "volatile" thread-local pool.
mVolatileFilePoolp = &AIThreadLocalData::tldata().mVolatileAPRPool;
@@ -193,7 +194,7 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc
apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool)
{
return open(filename, flags, use_global_pool ? LLAPRFile::global : LLAPRFile::local);
return open(filename, flags, use_global_pool ? LLAPRFile::long_lived : LLAPRFile::short_lived);
}
// File I/O
S32 LLAPRFile::read(void *buf, S32 nbytes)

View File

@@ -145,15 +145,15 @@ private:
public:
enum access_t {
global, // Use a global pool for long-lived file accesses. This should really only happen from the main thread.
local // Use a thread-local volatile pool for short file accesses.
long_lived, // Use a global pool for long-lived file accesses.
short_lived // Use a volatile pool for short-lived file accesses.
};
LLAPRFile() ;
LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global);
LLAPRFile(const std::string& filename, apr_int32_t flags, S32* sizep = NULL, access_t access_type = short_lived);
~LLAPRFile() ;
apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global, S32* sizep = NULL);
apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type = short_lived, S32* sizep = NULL);
apr_status_t open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool); //use global pool.
apr_status_t close() ;