diff options
28 files changed, 373 insertions, 373 deletions
diff --git a/bin/win64/01-window.exe b/bin/win64/01-window.exe Binary files differindex 6727afd..ce9e832 100644 --- a/bin/win64/01-window.exe +++ b/bin/win64/01-window.exe diff --git a/source/modules/asura-utils/io/binding/_file_data.cpp b/source/modules/asura-utils/io/binding/_file_data.cpp index 09a0643..f4f6584 100644 --- a/source/modules/asura-utils/io/binding/_file_data.cpp +++ b/source/modules/asura-utils/io/binding/_file_data.cpp @@ -52,7 +52,7 @@ namespace AsuraEngine LUAX_IMPL_METHOD(FileData, _GetDataBuffer) { LUAX_PREPARE(L, FileData); - self->PushLuaxMemberRef(state, self->mDataRef); + self->PushLuaxMemberRef(state, self->m_DataRef); return 1; } diff --git a/source/modules/asura-utils/io/binding/_file_system.cpp b/source/modules/asura-utils/io/binding/_file_system.cpp index 3843451..0dc24d0 100644 --- a/source/modules/asura-utils/io/binding/_file_system.cpp +++ b/source/modules/asura-utils/io/binding/_file_system.cpp @@ -206,8 +206,8 @@ namespace AsuraEngine FileData* fd = fs->Read(path); if (fd) { - fd->mData->PushLuaxUserdata(state); - fd->SetLuaxMemberRef(state, fd->mDataRef, -1); // fd->mDataRef = data buffer + fd->m_Data->PushLuaxUserdata(state); + fd->SetLuaxMemberRef(state, fd->m_DataRef, -1); // fd->m_DataRef = data buffer state.Pop(1); // data buffer fd->PushLuaxUserdata(state); } diff --git a/source/modules/asura-utils/io/binding/_io_task.cpp b/source/modules/asura-utils/io/binding/_io_task.cpp index b3c5988..4da8dc3 100644 --- a/source/modules/asura-utils/io/binding/_io_task.cpp +++ b/source/modules/asura-utils/io/binding/_io_task.cpp @@ -35,9 +35,9 @@ namespace AsuraEngine bool cbk = state.GetTop() >= 4 && state.IsType(4, LUA_TFUNCTION); IOTask* task = new IOTask(path, db, type); - task->SetLuaxMemberRef(state, task->mBufferRef, 2); + task->SetLuaxMemberRef(state, task->m_BufferRef, 2); if(cbk) - task->SetLuaxMemberRef(state, task->mCallback, 4); + task->SetLuaxMemberRef(state, task->m_Callback, 4); task->PushLuaxUserdata(state); return 1; } diff --git a/source/modules/asura-utils/io/data_buffer.cpp b/source/modules/asura-utils/io/data_buffer.cpp index 36e13c7..37f749c 100644 --- a/source/modules/asura-utils/io/data_buffer.cpp +++ b/source/modules/asura-utils/io/data_buffer.cpp @@ -10,15 +10,15 @@ namespace AsuraEngine { DataBuffer::DataBuffer(DataBuffer& src) - : mSize(0) - , mCapacity(0) - , mBytes(nullptr) + : m_Size(0) + , m_Capacity(0) + , m_Bytes(nullptr) { // ʼ - lock(mMutex) + lock(m_Mutex) { - mCapacity = src.mSize; - mBytes = new byte[mCapacity]; + m_Capacity = src.m_Size; + m_Bytes = new byte[m_Capacity]; Clear(); Load(src); @@ -26,27 +26,27 @@ namespace AsuraEngine } DataBuffer::DataBuffer(std::size_t capacity) - : mSize(0) - , mCapacity(0) - , mBytes(nullptr) + : m_Size(0) + , m_Capacity(0) + , m_Bytes(nullptr) { - lock(mMutex) + lock(m_Mutex) { - mCapacity = capacity; - mBytes = new byte[mCapacity]; + m_Capacity = capacity; + m_Bytes = new byte[m_Capacity]; Clear(); } } DataBuffer::DataBuffer(const void* data, std::size_t size) - : mCapacity(0) - , mSize(0) - , mBytes(nullptr) + : m_Capacity(0) + , m_Size(0) + , m_Bytes(nullptr) { - lock(mMutex) + lock(m_Mutex) { - mCapacity = size; - mBytes = new byte[mCapacity]; + m_Capacity = size; + m_Bytes = new byte[m_Capacity]; Clear(); Load(data, size); @@ -55,23 +55,23 @@ namespace AsuraEngine DataBuffer::~DataBuffer() { - lock(mMutex) + lock(m_Mutex) { - delete[] mBytes; + delete[] m_Bytes; } } void DataBuffer::Refactor(size_t capacity) { - lock(mMutex) + lock(m_Mutex) { - if (!mBytes || mCapacity != capacity) + if (!m_Bytes || m_Capacity != capacity) { - if(mBytes) - delete[] mBytes; - mCapacity = capacity; - mBytes = new byte[mCapacity]; - mSize = 0; + if(m_Bytes) + delete[] m_Bytes; + m_Capacity = capacity; + m_Bytes = new byte[m_Capacity]; + m_Size = 0; } Clear(); } @@ -79,7 +79,7 @@ namespace AsuraEngine void DataBuffer::Load(DataBuffer& db) { - lock(mMutex) + lock(m_Mutex) { Load(db.GetData(), db.GetSize()); } @@ -87,69 +87,69 @@ namespace AsuraEngine void DataBuffer::Load(const void* data, std::size_t size) { - lock(mMutex) + lock(m_Mutex) { - ASSERT(mCapacity >= size); - memcpy(mBytes, data, size); - mSize = size; + ASSERT(m_Capacity >= size); + memcpy(m_Bytes, data, size); + m_Size = size; } } void DataBuffer::Move(void* bytes, std::size_t size) { - lock(mMutex) + lock(m_Mutex) { - if (mBytes == bytes) + if (m_Bytes == bytes) { // sizeֵڶļʱ - mSize = size; + m_Size = size; } else { - if (mBytes) - delete[] mBytes; - mBytes = (byte*)bytes; - mSize = size; - mCapacity = size; + if (m_Bytes) + delete[] m_Bytes; + m_Bytes = (byte*)bytes; + m_Size = size; + m_Capacity = size; } } } byte* DataBuffer::GetData() { - return mBytes; + return m_Bytes; } void DataBuffer::Clear() { - lock(mMutex) + lock(m_Mutex) { - if (mBytes) + if (m_Bytes) { - memset(mBytes, 0, mSize); - mSize = 0; + memset(m_Bytes, 0, m_Size); + m_Size = 0; } } } std::size_t DataBuffer::GetSize() { - return mSize; + return m_Size; } std::size_t DataBuffer::GetCapacity() { - return mCapacity; + return m_Capacity; } void DataBuffer::Lock() { - mMutex.Lock(); + m_Mutex.Lock(); } void DataBuffer::Unlock() { - mMutex.Unlock(); + m_Mutex.Unlock(); } } diff --git a/source/modules/asura-utils/io/data_buffer.h b/source/modules/asura-utils/io/data_buffer.h index c60444e..53ed603 100644 --- a/source/modules/asura-utils/io/data_buffer.h +++ b/source/modules/asura-utils/io/data_buffer.h @@ -67,15 +67,15 @@ namespace AsuraEngine /// /// Bufferַݵij /// - byte* mBytes; - size_t mSize; + byte* m_Bytes; + size_t m_Size; /// /// Buffer /// - size_t mCapacity; + size_t m_Capacity; - AEThreading::Mutex mMutex; + AEThreading::Mutex m_Mutex; }; diff --git a/source/modules/asura-utils/io/file.cpp b/source/modules/asura-utils/io/file.cpp index 9e89c85..2061fb1 100644 --- a/source/modules/asura-utils/io/file.cpp +++ b/source/modules/asura-utils/io/file.cpp @@ -10,25 +10,25 @@ namespace AsuraEngine { File::File(const std::string& filename) - : mFileName(filename) - , mFileHandle(nullptr) - , mMode(FILE_MODE_CLOSED) - , mBufferMode(BUFFER_MODE_NONE) - , mBufferSize(0) + : m_FileName(filename) + , m_FileHandle(nullptr) + , m_Mode(FILE_MODE_CLOSED) + , m_BufferMode(BUFFER_MODE_NONE) + , m_BufferSize(0) { size_t dot = filename.rfind('.'); if (dot != std::string::npos) { - mExtension = filename.substr(dot + 1); - mName = filename.substr(0, dot); + m_Extension = filename.substr(dot + 1); + m_Name = filename.substr(0, dot); } else - mName = filename; + m_Name = filename; } File::~File() { - if (mMode != FILE_MODE_CLOSED) + if (m_Mode != FILE_MODE_CLOSED) Close(); } @@ -40,8 +40,8 @@ namespace AsuraEngine if (mode == FILE_MODE_CLOSED) return false; - if (mode == FILE_MODE_READ && !PHYSFS_exists(mFileName.c_str())) - throw Exception("Could NOT open file %s. Does not exist.", mFileName.c_str()); + if (mode == FILE_MODE_READ && !PHYSFS_exists(m_FileName.c_str())) + throw Exception("Could NOT open file %s. Does not exist.", m_FileName.c_str()); if (mode == FILE_MODE_APPEND || mode == FILE_MODE_WRITE) { @@ -52,7 +52,7 @@ namespace AsuraEngine } // Ѿ֮ǰͲٴµhandle - if (mFileHandle != nullptr) + if (m_FileHandle != nullptr) return true; PHYSFS_getLastErrorCode(); @@ -62,13 +62,13 @@ namespace AsuraEngine switch (mode) { case FILE_MODE_READ: - handle = PHYSFS_openRead(mFileName.c_str()); + handle = PHYSFS_openRead(m_FileName.c_str()); break; case FILE_MODE_APPEND: - handle = PHYSFS_openAppend(mFileName.c_str()); + handle = PHYSFS_openAppend(m_FileName.c_str()); break; case FILE_MODE_WRITE: - handle = PHYSFS_openWrite(mFileName.c_str()); + handle = PHYSFS_openWrite(m_FileName.c_str()); break; } @@ -77,45 +77,45 @@ namespace AsuraEngine const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); if (err == nullptr) err = "unknown error"; - throw Exception("Could not open file %s (%s)", mFileName.c_str(), err); + throw Exception("Could not open file %s (%s)", m_FileName.c_str(), err); } - mFileHandle = handle; - mMode = mode; + m_FileHandle = handle; + m_Mode = mode; - if (mFileHandle && !SetBuffer(mBufferMode,mBufferSize)) + if (m_FileHandle && !SetBuffer(m_BufferMode,m_BufferSize)) { - mBufferMode = BUFFER_MODE_NONE; - mBufferSize = 0; + m_BufferMode = BUFFER_MODE_NONE; + m_BufferSize = 0; } - return mFileHandle != nullptr; + return m_FileHandle != nullptr; } bool File::Close() { - if (mFileHandle == nullptr || !PHYSFS_close(mFileHandle)) + if (m_FileHandle == nullptr || !PHYSFS_close(m_FileHandle)) return false; - mMode = FILE_MODE_CLOSED; - mFileHandle = nullptr; + m_Mode = FILE_MODE_CLOSED; + m_FileHandle = nullptr; return true; } bool File::IsOpen() { - return mMode != FILE_MODE_CLOSED && mFileHandle != nullptr; + return m_Mode != FILE_MODE_CLOSED && m_FileHandle != nullptr; } size_t File::GetSize() { - if (mFileHandle == nullptr) + if (m_FileHandle == nullptr) { Open(FILE_MODE_READ); - size_t size = PHYSFS_fileLength(mFileHandle); + size_t size = PHYSFS_fileLength(m_FileHandle); Close(); return size; } - return PHYSFS_fileLength(mFileHandle); + return PHYSFS_fileLength(m_FileHandle); } size_t File::Read(ASURA_OUT DataBuffer* dst, size_t length) @@ -125,17 +125,17 @@ namespace AsuraEngine if (dst->GetCapacity() < length) throw Exception("Data buffer is too small compares to read length."); - if (!mFileHandle || mMode != FILE_MODE_READ) - throw Exception("File \"%s\" is not opened for reading", mFileName); + if (!m_FileHandle || m_Mode != FILE_MODE_READ) + throw Exception("File \"%s\" is not opened for reading", m_FileName); - size_t max = PHYSFS_fileLength(mFileHandle); + size_t max = PHYSFS_fileLength(m_FileHandle); length = (length > max) ? max : length; if (length < 0) throw Exception("Invalid read size."); dst->Lock(); - size_t size = PHYSFS_readBytes(mFileHandle, dst->GetData(), length); + size_t size = PHYSFS_readBytes(m_FileHandle, dst->GetData(), length); dst->Unlock(); return size; } @@ -144,17 +144,17 @@ namespace AsuraEngine { ASSERT(dst); - if (!mFileHandle || mMode != FILE_MODE_READ) - throw Exception("File \"%s\" is not opened for reading", mFileName); + if (!m_FileHandle || m_Mode != FILE_MODE_READ) + throw Exception("File \"%s\" is not opened for reading", m_FileName); - size_t length = PHYSFS_fileLength(mFileHandle); + size_t length = PHYSFS_fileLength(m_FileHandle); if (dst->GetCapacity() < length) throw Exception("Data buffer is too small compares to file length."); dst->Lock(); byte* data = dst->GetData(); - size_t size = PHYSFS_readBytes(mFileHandle, data, length); + size_t size = PHYSFS_readBytes(m_FileHandle, data, length); dst->Move(data, length); dst->Unlock(); return size; @@ -176,25 +176,25 @@ namespace AsuraEngine bool File::IsEOF() { - return mFileHandle == nullptr || test_eof(this, mFileHandle); + return m_FileHandle == nullptr || test_eof(this, m_FileHandle); } size_t File::Tell() { - if (!mFileHandle) + if (!m_FileHandle) return - 1; - return PHYSFS_tell(mFileHandle); + return PHYSFS_tell(m_FileHandle); } bool File::Seek(size_t pos) { - return mFileHandle != nullptr && PHYSFS_seek(mFileHandle, pos) != 0; + return m_FileHandle != nullptr && PHYSFS_seek(m_FileHandle, pos) != 0; } bool File::Write(ASURA_REF DataBuffer* src) { - if (!mFileHandle || (mMode != FILE_MODE_APPEND && mMode != FILE_MODE_WRITE)) + if (!m_FileHandle || (m_Mode != FILE_MODE_APPEND && m_Mode != FILE_MODE_WRITE)) throw Exception("File is not opened for writing."); byte* data = src->GetData(); @@ -203,13 +203,13 @@ namespace AsuraEngine if (size < 0) throw Exception("Invalid write size."); - size_t written = PHYSFS_writeBytes(mFileHandle, data, size); + size_t written = PHYSFS_writeBytes(m_FileHandle, data, size); if (written != src->GetSize()) return false; // л - if (mBufferSize == BUFFER_MODE_LINE && mBufferSize > size) + if (m_BufferSize == BUFFER_MODE_LINE && m_BufferSize > size) { if (memchr(data, '\n', size) != nullptr) Flush(); @@ -220,10 +220,10 @@ namespace AsuraEngine bool File::Flush() { - if (!mFileHandle || (mMode != FILE_MODE_WRITE && mMode != FILE_MODE_APPEND)) + if (!m_FileHandle || (m_Mode != FILE_MODE_WRITE && m_Mode != FILE_MODE_APPEND)) throw Exception("File is not opened for writing."); - return PHYSFS_flush(mFileHandle) != 0; + return PHYSFS_flush(m_FileHandle) != 0; } bool File::SetBuffer(BufferMode mode, size_t size) @@ -235,8 +235,8 @@ namespace AsuraEngine // File::open. if (!IsOpen()) { - mBufferMode = mode; - mBufferSize = size; + m_BufferMode = mode; + m_BufferSize = size; return true; } @@ -246,48 +246,48 @@ namespace AsuraEngine { case BUFFER_MODE_NONE: default: - ret = PHYSFS_setBuffer(mFileHandle, 0); + ret = PHYSFS_setBuffer(m_FileHandle, 0); size = 0; break; case BUFFER_MODE_LINE: case BUFFER_MODE_FULL: - ret = PHYSFS_setBuffer(mFileHandle, size); + ret = PHYSFS_setBuffer(m_FileHandle, size); break; } if (ret == 0) return false; - mBufferMode = mode; - mBufferSize = size; + m_BufferMode = mode; + m_BufferSize = size; return true; } File::BufferMode File::GetBuffer(ASURA_OUT size_t& size) { - size = mBufferSize; - return mBufferMode; + size = m_BufferSize; + return m_BufferMode; } const std::string& File::GetFileName() { - return mFileName; + return m_FileName; } const std::string& File::GetName() { - return mName; + return m_Name; } const std::string& File::GetExtension() { - return mExtension; + return m_Extension; } File::FileMode File::GetMode() { - return mMode; + return m_Mode; } } diff --git a/source/modules/asura-utils/io/file.h b/source/modules/asura-utils/io/file.h index 56077e0..16de42b 100644 --- a/source/modules/asura-utils/io/file.h +++ b/source/modules/asura-utils/io/file.h @@ -107,13 +107,13 @@ namespace AsuraEngine private: - PHYSFS_File* mFileHandle; ///< physfs ļ - std::string mFileName; ///< ļ - std::string mExtension; ///< չ - std::string mName; ///< չļ - FileMode mMode; ///< ļģʽ - BufferMode mBufferMode; ///< д뻺ģʽ - size_t mBufferSize; ///< д뻺С + PHYSFS_File* m_FileHandle; ///< physfs ļ + std::string m_FileName; ///< ļ + std::string m_Extension; ///< չ + std::string m_Name; ///< չļ + FileMode m_Mode; ///< ļģʽ + BufferMode m_BufferMode; ///< д뻺ģʽ + size_t m_BufferSize; ///< д뻺С LUAX_DECL_ENUM(FileMode); LUAX_DECL_ENUM(BufferMode); diff --git a/source/modules/asura-utils/io/file_data.cpp b/source/modules/asura-utils/io/file_data.cpp index ad58db9..30fa5bf 100644 --- a/source/modules/asura-utils/io/file_data.cpp +++ b/source/modules/asura-utils/io/file_data.cpp @@ -6,53 +6,53 @@ namespace AsuraEngine { FileData::FileData(const std::string& filename) - : mData(nullptr) - , mFileName(filename) + : m_Data(nullptr) + , m_FileName(filename) { size_t dot = filename.rfind('.'); if (dot != std::string::npos) { - mExtension = filename.substr(dot + 1); - mName = filename.substr(0, dot); + m_Extension = filename.substr(dot + 1); + m_Name = filename.substr(0, dot); } else - mName = filename; + m_Name = filename; } FileData::~FileData() { - if (mData) - mData->Release(); + if (m_Data) + m_Data->Release(); } const std::string& FileData::GetFileName() { - return mFileName; + return m_FileName; } const std::string& FileData::GetExtension() { - return mExtension; + return m_Extension; } const std::string& FileData::GetName() { - return mName; + return m_Name; } void FileData::BindData(ASURA_MOVE DataBuffer* buffer) { if (!buffer) return; - if (mData) - mData->Release(); - mData = buffer; - mData->Retain(); + if (m_Data) + m_Data->Release(); + m_Data = buffer; + m_Data->Retain(); } DataBuffer* FileData::GetDataBuffer() { - return mData; + return m_Data; } } diff --git a/source/modules/asura-utils/io/file_data.h b/source/modules/asura-utils/io/file_data.h index cd69477..ecc072b 100644 --- a/source/modules/asura-utils/io/file_data.h +++ b/source/modules/asura-utils/io/file_data.h @@ -49,12 +49,12 @@ namespace AsuraEngine /// /// Data bufferfiledataʱ٣luaüΪ0ʱluaGC١mDataʱһԱá /// - ASURA_REF DataBuffer* mData; - Luax::LuaxMemberRef mDataRef; + ASURA_REF DataBuffer* m_Data; + Luax::LuaxMemberRef m_DataRef; - std::string mFileName; ///< չļ - std::string mExtension; ///< չ - std::string mName; ///< ͺļ + std::string m_FileName; ///< չļ + std::string m_Extension; ///< չ + std::string m_Name; ///< ͺļ LUAX_DECL_METHOD(_GetDataBuffer); LUAX_DECL_METHOD(_GetFileName); diff --git a/source/modules/asura-utils/io/file_system.cpp b/source/modules/asura-utils/io/file_system.cpp index 20f3cb2..f68bad6 100644 --- a/source/modules/asura-utils/io/file_system.cpp +++ b/source/modules/asura-utils/io/file_system.cpp @@ -23,7 +23,7 @@ namespace AsuraEngine Filesystem::~Filesystem() { - if (mInited) //PHYSFS_isInit + if (m_Inited) //PHYSFS_isInit PHYSFS_deinit(); } @@ -32,12 +32,12 @@ namespace AsuraEngine if (!PHYSFS_init(arg0)) throw Exception("Failed to initialize filesystem: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); - mInited = true; + m_Inited = true; } bool Filesystem::Mount(const std::string& locpath, const std::string& montpoint/* = "/"*/, bool prepend /*= false*/) { - if (!mInited) + if (!m_Inited) return false; return PHYSFS_mount(locpath.c_str(), montpoint.c_str(), !prepend); @@ -45,11 +45,11 @@ namespace AsuraEngine bool Filesystem::Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint /*= "/"*/, bool prepend /*= false*/) { - if (!mInited) + if (!m_Inited) return false; if (PHYSFS_mountMemory(db->GetData(), db->GetSize(), nullptr, archivename.c_str(), mountpoint.c_str(), !prepend)) { - mMountData[archivename] = db; + m_MountData[archivename] = db; return true; } return false; @@ -57,14 +57,14 @@ namespace AsuraEngine bool Filesystem::Unmount(const std::string& locpath) { - if (!mInited) + if (!m_Inited) return false; // ǹ鵵ӳɾ - auto datait = mMountData.find(locpath); - if (datait != mMountData.end() && PHYSFS_unmount(locpath.c_str()) != 0) + auto datait = m_MountData.find(locpath); + if (datait != m_MountData.end() && PHYSFS_unmount(locpath.c_str()) != 0) { - mMountData.erase(datait); + m_MountData.erase(datait); return true; } @@ -73,7 +73,7 @@ namespace AsuraEngine bool Filesystem::Unmount(DataBuffer* db) { - for (const auto& dp : mMountData) + for (const auto& dp : m_MountData) { if (dp.second == db) { @@ -85,7 +85,7 @@ namespace AsuraEngine bool Filesystem::GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint) { - if (!mInited) + if (!m_Inited) return false; const char* point = PHYSFS_getMountPoint(locpath.c_str()); if (point != nullptr) @@ -98,7 +98,7 @@ namespace AsuraEngine void Filesystem::SetWriteDirectory(const std::string locpath) { - if (!mInited) + if (!m_Inited) return; if (!PHYSFS_setWriteDir(locpath.c_str())) throw Exception("Failed to set write directory %s", locpath.c_str()); @@ -116,7 +116,7 @@ namespace AsuraEngine bool Filesystem::NewDirectory(const std::string& path) { - if (!mInited) + if (!m_Inited) return false; if (!PHYSFS_getWriteDir()) return false; @@ -159,7 +159,7 @@ namespace AsuraEngine bool Filesystem::Remove(const std::string& path) { - if (!mInited) + if (!m_Inited) return false; if (PHYSFS_getWriteDir() == 0) return false; @@ -172,7 +172,7 @@ namespace AsuraEngine bool Filesystem::GetFileInfo(const std::string& filepath, ASURA_OUT FileInfo* info) { - if (!mInited) + if (!m_Inited) return false; PHYSFS_Stat stat = {}; diff --git a/source/modules/asura-utils/io/file_system.h b/source/modules/asura-utils/io/file_system.h index 849cbb6..9b4c4be 100644 --- a/source/modules/asura-utils/io/file_system.h +++ b/source/modules/asura-utils/io/file_system.h @@ -78,9 +78,9 @@ namespace AsuraEngine typedef std::map<std::string, DataBuffer*> MountDataMap; - bool mInited; ///< Ƿʼɹ - std::string mCwd; ///< ǰִļĹĿ¼ - MountDataMap mMountData; ///< ·ѹĵӳ + bool m_Inited; ///< Ƿʼɹ + std::string m_Cwd; ///< ǰִļĹĿ¼ + MountDataMap m_MountData; ///< ·ѹĵӳ LUAX_DECL_METHOD(_Init); LUAX_DECL_METHOD(_Mount); diff --git a/source/modules/asura-utils/io/io_batch_task.h b/source/modules/asura-utils/io/io_batch_task.h index c0be921..0a551e8 100644 --- a/source/modules/asura-utils/io/io_batch_task.h +++ b/source/modules/asura-utils/io/io_batch_task.h @@ -21,7 +21,7 @@ namespace AsuraEngine /// ÿһĽṹ£ /// { path = "", } /// - Luax::LuaxMemberRef mTasks; + Luax::LuaxMemberRef m_Tasks; }; diff --git a/source/modules/asura-utils/io/io_task.cpp b/source/modules/asura-utils/io/io_task.cpp index ca03b09..6c323de 100644 --- a/source/modules/asura-utils/io/io_task.cpp +++ b/source/modules/asura-utils/io/io_task.cpp @@ -12,8 +12,8 @@ namespace AsuraEngine { IOTask::IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type) - : mPath(path) - , mBuffer(buffer) + : m_Path(path) + , m_Buffer(buffer) { if (buffer) buffer->Retain(); @@ -21,24 +21,24 @@ namespace AsuraEngine IOTask::~IOTask() { - if (mBuffer) - mBuffer->Release(); + if (m_Buffer) + m_Buffer->Release(); } bool IOTask::Execute() { - File file(mPath); - if (mType == IOTASK_TYPE_WRITE) + File file(m_Path); + if (m_Type == IOTASK_TYPE_WRITE) { } // pathȡݱmBuffer - else if (mType == IOTASK_TYPE_READ) + else if (m_Type == IOTASK_TYPE_READ) { - if (!mBuffer) + if (!m_Buffer) return false; file.Open(File::FILE_MODE_READ); - file.ReadAll(mBuffer); + file.ReadAll(m_Buffer); file.Close(); } return true; @@ -46,12 +46,12 @@ namespace AsuraEngine void IOTask::Invoke(lua_State* invokeThreaad) { - if (mCallback) + if (m_Callback) { LuaxScopedState state(invokeThreaad); - if (this->PushLuaxMemberRef(state, mCallback)) + if (this->PushLuaxMemberRef(state, m_Callback)) { - this->PushLuaxMemberRef(state, mBufferRef); + this->PushLuaxMemberRef(state, m_BufferRef); state.Call(1, 0); } } diff --git a/source/modules/asura-utils/io/io_task.h b/source/modules/asura-utils/io/io_task.h index 0cf5023..8026a24 100644 --- a/source/modules/asura-utils/io/io_task.h +++ b/source/modules/asura-utils/io/io_task.h @@ -42,11 +42,11 @@ namespace AsuraEngine LUAX_DECL_METHOD(_New); - std::string mPath; - IOTaskType mType; + std::string m_Path; + IOTaskType m_Type; - DataBuffer* mBuffer; - Luax::LuaxMemberRef mBufferRef; + DataBuffer* m_Buffer; + Luax::LuaxMemberRef m_BufferRef; }; diff --git a/source/modules/asura-utils/threading/binding/_thread.cpp b/source/modules/asura-utils/threading/binding/_thread.cpp index ad2fb7f..ae43242 100644 --- a/source/modules/asura-utils/threading/binding/_thread.cpp +++ b/source/modules/asura-utils/threading/binding/_thread.cpp @@ -185,7 +185,7 @@ namespace AsuraEngine LUAX_IMPL_METHOD(Thread, _GetType) { LUAX_PREPARE(L, Thread); - state.Push(self->mType); + state.Push(self->m_Type); return 1; } @@ -193,7 +193,7 @@ namespace AsuraEngine LUAX_IMPL_METHOD(Thread, _GetState) { LUAX_PREPARE(L, Thread); - state.Push(self->mState); + state.Push(self->m_State); return 1; } diff --git a/source/modules/asura-utils/threading/conditional.cpp b/source/modules/asura-utils/threading/conditional.cpp index eb26e82..e49bfde 100644 --- a/source/modules/asura-utils/threading/conditional.cpp +++ b/source/modules/asura-utils/threading/conditional.cpp @@ -6,8 +6,8 @@ namespace AsuraEngine { Conditional::Conditional() - : mWaiting(0) - , mSignals(0) + : m_Waiting(0) + , m_Signals(0) { } @@ -17,38 +17,38 @@ namespace AsuraEngine void Conditional::Signal() { - mMutex.Lock(); - if (mWaiting > mSignals) + m_Mutex.Lock(); + if (m_Waiting > m_Signals) { - ++mSignals; - signal(mWaitSem); - mMutex.Unlock(); - wait(mDoneSem); + ++m_Signals; + signal(m_WaitSem); + m_Mutex.Unlock(); + wait(m_DoneSem); } else { - mMutex.Unlock(); + m_Mutex.Unlock(); } } void Conditional::Broadcast() { - mMutex.Lock(); - if (mWaiting> mSignals) { + m_Mutex.Lock(); + if (m_Waiting> m_Signals) { int i, num_waiting; - num_waiting = (mWaiting - mSignals); - mSignals = mWaiting; + num_waiting = (m_Waiting - m_Signals); + m_Signals = m_Waiting; for (i = 0; i < num_waiting; ++i) { - signal(mWaitSem); + signal(m_WaitSem); } - mMutex.Unlock(); + m_Mutex.Unlock(); for (i = 0; i < num_waiting; ++i) { - wait(mDoneSem); + wait(m_DoneSem); } } else { - mMutex.Unlock(); + m_Mutex.Unlock(); } } @@ -57,27 +57,27 @@ namespace AsuraEngine { bool retval; - mMutex.Lock(); - ++mWaiting; - mMutex.Unlock(); + m_Mutex.Lock(); + ++m_Waiting; + m_Mutex.Unlock(); mutex->Unlock(); - retval = wait(mWaitSem, timeout); + retval = wait(m_WaitSem, timeout); - mMutex.Lock(); - if (mSignals > 0) { + m_Mutex.Lock(); + if (m_Signals > 0) { if (!retval) { - wait(mWaitSem); + wait(m_WaitSem); } - signal(mDoneSem); + signal(m_DoneSem); - --mSignals; + --m_Signals; } - --mWaiting; - mMutex.Unlock(); + --m_Waiting; + m_Mutex.Unlock(); - mMutex.Lock(); + m_Mutex.Lock(); return retval; } diff --git a/source/modules/asura-utils/threading/conditional.h b/source/modules/asura-utils/threading/conditional.h index 2f9633e..3aee392 100644 --- a/source/modules/asura-utils/threading/conditional.h +++ b/source/modules/asura-utils/threading/conditional.h @@ -25,13 +25,13 @@ namespace AsuraEngine private: - Mutex mMutex; + Mutex m_Mutex; - Semaphore mWaitSem; - Semaphore mDoneSem; + Semaphore m_WaitSem; + Semaphore m_DoneSem; - int mWaiting; - int mSignals; + int m_Waiting; + int m_Signals; }; diff --git a/source/modules/asura-utils/threading/coroutine.h b/source/modules/asura-utils/threading/coroutine.h index 01af654..bd0f922 100644 --- a/source/modules/asura-utils/threading/coroutine.h +++ b/source/modules/asura-utils/threading/coroutine.h @@ -25,7 +25,7 @@ namespace AsuraEngine /// /// ǰЭ̵state /// - lua_State* mThreadState; + lua_State* m_ThreadState; LUAX_DECL_METHOD(_New); LUAX_DECL_METHOD(_Run); diff --git a/source/modules/asura-utils/threading/mutex.cpp b/source/modules/asura-utils/threading/mutex.cpp index bd7d419..a36af1b 100644 --- a/source/modules/asura-utils/threading/mutex.cpp +++ b/source/modules/asura-utils/threading/mutex.cpp @@ -8,20 +8,20 @@ namespace AsuraEngine { #define try_create_mutex(impl)\ - if (!mImpl) \ + if (!m_Impl) \ { \ try \ { \ - mImpl = new impl(); \ + m_Impl = new impl(); \ } \ catch (Exception& e) \ { \ - mImpl = nullptr; \ + m_Impl = nullptr; \ } \ } Mutex::Mutex() - : mImpl(nullptr) + : m_Impl(nullptr) { #if ASURA_MUTEX_WIN32_CRITICLE_SECTION try_create_mutex(MutexImplWin32_CS); @@ -29,49 +29,49 @@ namespace AsuraEngine #if ASURA_MUTEX_WIN32_KERNAL_MUTEX try_create_mutex(MutexImplWin32_KM); #endif - ASSERT(mImpl); + ASSERT(m_Impl); } Mutex::~Mutex() { - if(mImpl) - delete mImpl; + if(m_Impl) + delete m_Impl; } void Mutex::Lock() { - ASSERT(mImpl); + ASSERT(m_Impl); - mImpl->Lock(); + m_Impl->Lock(); } void Mutex::Unlock() { - ASSERT(mImpl); + ASSERT(m_Impl); - mImpl->Unlock(); + m_Impl->Unlock(); } #if ASURA_MUTEX_WIN32_CRITICLE_SECTION MutexImplWin32_CS::MutexImplWin32_CS() { - ::InitializeCriticalSection(&mMutex); + ::InitializeCriticalSection(&m_Mutex); } MutexImplWin32_CS::~MutexImplWin32_CS() { - ::DeleteCriticalSection(&mMutex); + ::DeleteCriticalSection(&m_Mutex); } void MutexImplWin32_CS::Lock() { - ::EnterCriticalSection(&mMutex); + ::EnterCriticalSection(&m_Mutex); } void MutexImplWin32_CS::Unlock() { - ::LeaveCriticalSection(&mMutex); + ::LeaveCriticalSection(&m_Mutex); } #endif // ASURA_MUTEX_WIN32_CRITICLE_SECTION @@ -80,25 +80,25 @@ namespace AsuraEngine MutexImplWin32_KM::MutexImplWin32_KM() { - mHandle = ::CreateMutex(NULL, FALSE, NULL); - if (!mHandle) + m_Handle = ::CreateMutex(NULL, FALSE, NULL); + if (!m_Handle) throw Exception("Cant use win32 mutex."); } MutexImplWin32_KM::~MutexImplWin32_KM() { - ::CloseHandle(mHandle); - mHandle = NULL; + ::CloseHandle(m_Handle); + m_Handle = NULL; } void MutexImplWin32_KM::Lock() { - ::WaitForSingleObject(mHandle, ASURA_MUTEX_MAXWAIT); + ::WaitForSingleObject(m_Handle, ASURA_MUTEX_MAXWAIT); } void MutexImplWin32_KM::Unlock() { - ::ReleaseMutex(mHandle); + ::ReleaseMutex(m_Handle); } #endif // ASURA_MUTEX_WIN32_KERNAL_MUTEX diff --git a/source/modules/asura-utils/threading/mutex.h b/source/modules/asura-utils/threading/mutex.h index 5d33be1..9e9d2c2 100644 --- a/source/modules/asura-utils/threading/mutex.h +++ b/source/modules/asura-utils/threading/mutex.h @@ -34,7 +34,7 @@ namespace AsuraEngine Mutex(const Mutex&); Mutex& operator=(const Mutex&); - MutexImpl* mImpl; + MutexImpl* m_Impl; }; @@ -86,8 +86,8 @@ namespace AsuraEngine private: - //HANDLE mHandle; - CRITICAL_SECTION mMutex; + //HANDLE m_Handle; + CRITICAL_SECTION m_Mutex; }; @@ -107,7 +107,7 @@ namespace AsuraEngine private: - HANDLE mHandle; + HANDLE m_Handle; }; diff --git a/source/modules/asura-utils/threading/semaphore.cpp b/source/modules/asura-utils/threading/semaphore.cpp index aa5d9dd..7e5ccf5 100644 --- a/source/modules/asura-utils/threading/semaphore.cpp +++ b/source/modules/asura-utils/threading/semaphore.cpp @@ -10,42 +10,42 @@ namespace AsuraEngine { #define try_create_semaphore(impl) \ - if (!mImpl) \ + if (!m_Impl) \ { \ try \ { \ - mImpl = new impl(init_count); \ + m_Impl = new impl(init_count); \ } \ catch (Exception& e) \ { \ - mImpl = nullptr; \ + m_Impl = nullptr; \ } \ } Semaphore::Semaphore(unsigned int init_count) - : mImpl(nullptr) + : m_Impl(nullptr) { #ifdef ASURA_THREAD_WIN32 try_create_semaphore(SemaphoreWin32); #endif - //ASSERT(mImpl); + //ASSERT(m_Impl); } Semaphore::~Semaphore() { - if (mImpl) delete mImpl; + if (m_Impl) delete m_Impl; } void Semaphore::Signal() { - ASSERT(mImpl); - mImpl->Signal(); + ASSERT(m_Impl); + m_Impl->Signal(); } bool Semaphore::Wait(int timeout /*= ASURA_MUTEX_MAXWAIT*/) { - ASSERT(mImpl); - return mImpl->Wait(timeout); + ASSERT(m_Impl); + return m_Impl->Wait(timeout); } #if ASURA_THREAD_WIN32 @@ -54,8 +54,8 @@ namespace AsuraEngine : SemaphoreImpl(init_value) { // UINT_MAX get error. - mSem = CreateSemaphore(NULL, init_value, INT_MAX, NULL); - if (!mSem) + m_Sem = CreateSemaphore(NULL, init_value, INT_MAX, NULL); + if (!m_Sem) { int errorCode = GetLastError(); throw Exception("Cant use win32 semaphore. Error code: %d.", errorCode); @@ -64,23 +64,23 @@ namespace AsuraEngine SemaphoreWin32::~SemaphoreWin32() { - CloseHandle(mSem); + CloseHandle(m_Sem); } void SemaphoreWin32::Signal() { - InterlockedIncrement(&mCount); - if (ReleaseSemaphore(mSem, 1, NULL) == FALSE) - InterlockedDecrement(&mCount); + InterlockedIncrement(&m_Count); + if (ReleaseSemaphore(m_Sem, 1, NULL) == FALSE) + InterlockedDecrement(&m_Count); } bool SemaphoreWin32::Wait(int timeout) { int result; - result = WaitForSingleObject(mSem, timeout); + result = WaitForSingleObject(m_Sem, timeout); if (result == WAIT_OBJECT_0) { - InterlockedDecrement(&mCount); + InterlockedDecrement(&m_Count); return true; } else if(result == WAIT_TIMEOUT) diff --git a/source/modules/asura-utils/threading/semaphore.h b/source/modules/asura-utils/threading/semaphore.h index 1a4e3b7..c75ae8a 100644 --- a/source/modules/asura-utils/threading/semaphore.h +++ b/source/modules/asura-utils/threading/semaphore.h @@ -28,22 +28,22 @@ namespace AsuraEngine bool Wait(int timeout = ASURA_MUTEX_MAXWAIT); private: - SemaphoreImpl* mImpl; + SemaphoreImpl* m_Impl; }; class SemaphoreImpl { public: SemaphoreImpl(unsigned int init_value) - : mCount(init_value) + : m_Count(init_value) { }; virtual ~SemaphoreImpl() {}; virtual void Signal() = 0; virtual bool Wait(int timeout) = 0; - inline int Current() { return mCount; } + inline int Current() { return m_Count; } protected: - unsigned int mCount; + unsigned int m_Count; }; #define wait(sem, ...) sem.Wait(__VA_ARGS__) @@ -59,7 +59,7 @@ namespace AsuraEngine void Signal() override; bool Wait(int timeout) override; private: - HANDLE mSem; + HANDLE m_Sem; }; #endif // ASURA_THREAD_WIN32 diff --git a/source/modules/asura-utils/threading/task.h b/source/modules/asura-utils/threading/task.h index 9073045..6461fff 100644 --- a/source/modules/asura-utils/threading/task.h +++ b/source/modules/asura-utils/threading/task.h @@ -32,7 +32,7 @@ namespace AsuraEngine protected: // ȡص - Luax::LuaxMemberRef mCallback; + Luax::LuaxMemberRef m_Callback; }; diff --git a/source/modules/asura-utils/threading/thread.cpp b/source/modules/asura-utils/threading/thread.cpp index 0899485..48f287f 100644 --- a/source/modules/asura-utils/threading/thread.cpp +++ b/source/modules/asura-utils/threading/thread.cpp @@ -11,217 +11,217 @@ namespace AsuraEngine { Thread::Thread(lua_State* luaThread, ThreadType type /*= THREAD_TYPE_DEFERRED*/, uint sleepTime /*= 0*/, const std::string& name /*= ""*/) - : mName(name) - , mState(THREAD_STATE_IDLE) - , mType(type) - , mLuaThread(luaThread) - , mCallbackThread(nullptr) - , mSleepTime(sleepTime) + : m_Name(name) + , m_State(THREAD_STATE_IDLE) + , m_Type(type) + , m_LuaThread(luaThread) + , m_CallbackThread(nullptr) + , m_SleepTime(sleepTime) { LUAX_STATE(luaThread); if (type == THREAD_TYPE_IMMEDIATE) { Luax::LuaxVM* vm = state.GetVM(); ASSERT(vm); - mCallbackThread = vm->CreateThread(); - ASSERT(mCallbackThread); - SetLuaxMemberRef(state, mCallbackThreadRef, -1); + m_CallbackThread = vm->CreateThread(); + ASSERT(m_CallbackThread); + SetLuaxMemberRef(state, m_CallbackThreadRef, -1); state.Pop(); // callback thread } } Thread::~Thread() { - if (mImpl) + if (m_Impl) { - delete mImpl; - mImpl = nullptr; + delete m_Impl; + m_Impl = nullptr; } } bool Thread::AddTask(Task* task) { - lock(mTaskQueueMutex) + lock(m_TaskQueueMutex) { task->Retain(); - mTaskQueue.push(task); + m_TaskQueue.push(task); } return true; } uint Thread::GetTaskCount() { - return mTaskQueue.size(); + return m_TaskQueue.size(); } void Thread::Idle() { - mState = THREAD_STATE_IDLE; + m_State = THREAD_STATE_IDLE; } #define try_start_thread(impl)\ - if (!mImpl) \ + if (!m_Impl) \ { \ - mImpl = new impl(); \ - if (!mImpl->Start(this, stacksize)) \ + m_Impl = new impl(); \ + if (!m_Impl->Start(this, stacksize)) \ { \ - delete mImpl; \ - mImpl = nullptr; \ + delete m_Impl; \ + m_Impl = nullptr; \ } \ } bool Thread::Start(bool isDaemon /*= true*/, uint32 stacksize /*= 0*/) { - if (mState != THREAD_STATE_IDLE) + if (m_State != THREAD_STATE_IDLE) return false; // Ѿһ֮ǰģر - if (mImpl) + if (m_Impl) { - delete mImpl; - mImpl = nullptr; + delete m_Impl; + m_Impl = nullptr; } #if ASURA_THREAD_WIN32 try_start_thread(ThreadImplWin32); #endif - if (!mImpl) + if (!m_Impl) return false; - mIsDaemon = isDaemon; - mStateMutex.Lock(); - mState = THREAD_STATE_RUNNING; - mStateMutex.Unlock(); + m_IsDaemon = isDaemon; + m_StateMutex.Lock(); + m_State = THREAD_STATE_RUNNING; + m_StateMutex.Unlock(); } void Thread::Pause() { - ASSERT(mImpl); + ASSERT(m_Impl); - lock(mStateMutex) + lock(m_StateMutex) { - mState = THREAD_STATE_PAUSED; + m_State = THREAD_STATE_PAUSED; } } void Thread::Resume() { - ASSERT(mImpl); + ASSERT(m_Impl); - lock(mStateMutex) + lock(m_StateMutex) { - if (mState == THREAD_STATE_PAUSED) - mState = THREAD_STATE_RUNNING; + if (m_State == THREAD_STATE_PAUSED) + m_State = THREAD_STATE_RUNNING; } } void Thread::Stop() { - ASSERT(mImpl); + ASSERT(m_Impl); - lock(mStateMutex) + lock(m_StateMutex) { - mState = THREAD_STATE_STOPPED; + m_State = THREAD_STATE_STOPPED; } } void Thread::PauseSync() { Pause(); - wait(mSemPause); + wait(m_SemPause); } void Thread::ResumeSync() { Resume(); - wait(mSemResume); + wait(m_SemResume); } void Thread::StopSync() { Stop(); - wait(mSemStop); + wait(m_SemStop); } void Thread::Join() { - ASSERT(mImpl); - mImpl->Join(); + ASSERT(m_Impl); + m_Impl->Join(); } ThreadState Thread::GetState() { ThreadState state; - lock(mStateMutex) + lock(m_StateMutex) { - state = mState; + state = m_State; } return state; } bool Thread::IsRunning() { - ASSERT(mImpl); + ASSERT(m_Impl); return GetState() == THREAD_STATE_RUNNING; } bool Thread::IsPaused() { - ASSERT(mImpl); + ASSERT(m_Impl); return GetState() == THREAD_STATE_PAUSED; } bool Thread::IsStopped() { - ASSERT(mImpl); + ASSERT(m_Impl); return GetState() == THREAD_STATE_STOPPED; } bool Thread::IsCurrent() { - ASSERT(mImpl); + ASSERT(m_Impl); - return mImpl->IsCurrent(); + return m_Impl->IsCurrent(); } const std::string& Thread::GetName() { - return mName; + return m_Name; } int Thread::Process() { - LUAX_STATE(mLuaThread); + LUAX_STATE(m_LuaThread); do{ if (IsRunning()) { - while (!mTaskQueue.empty()) + while (!m_TaskQueue.empty()) { - Task* task = mTaskQueue.front(); + Task* task = m_TaskQueue.front(); if (task && task->Execute()) { - if (mType == THREAD_TYPE_DEFERRED) + if (m_Type == THREAD_TYPE_DEFERRED) { - mFinishedMutex.Lock(); + m_FinishedMutex.Lock(); task->Retain(); - mFinishedTasks.push(task); - mFinishedMutex.Unlock(); + m_FinishedTasks.push(task); + m_FinishedMutex.Unlock(); } - else if (mType == THREAD_TYPE_IMMEDIATE) + else if (m_Type == THREAD_TYPE_IMMEDIATE) { // unsafe - task->Invoke(mCallbackThread); + task->Invoke(m_CallbackThread); this->LuaxRelease<Task>(state, task); } - mTaskQueueMutex.Lock(); - mTaskQueue.pop(); + m_TaskQueueMutex.Lock(); + m_TaskQueue.pop(); task->Release(); - mTaskQueueMutex.Unlock(); + m_TaskQueueMutex.Unlock(); } } } @@ -231,15 +231,15 @@ namespace AsuraEngine break; // CPUʹ - Sleep(mSleepTime); + Sleep(m_SleepTime); - } while (mIsDaemon); + } while (m_IsDaemon); // ػ̣߳еstop״̬ - if (!mIsDaemon) + if (!m_IsDaemon) Stop(); - signal(mSemStop); + signal(m_SemStop); // ״̬ΪIdle Idle(); @@ -252,37 +252,37 @@ namespace AsuraEngine /// void Thread::Dispatch() { - if (mType != THREAD_TYPE_DEFERRED) + if (m_Type != THREAD_TYPE_DEFERRED) return; - LUAX_STATE(mLuaThread); - while (!mFinishedTasks.empty()) + LUAX_STATE(m_LuaThread); + while (!m_FinishedTasks.empty()) { - Task* task = mFinishedTasks.front(); + Task* task = m_FinishedTasks.front(); if (task) { - task->Invoke(mLuaThread); + task->Invoke(m_LuaThread); this->LuaxRelease<Task>(state, task); - mFinishedMutex.Lock(); - mFinishedTasks.pop(); + m_FinishedMutex.Lock(); + m_FinishedTasks.pop(); task->Release(); - mFinishedMutex.Unlock(); + m_FinishedMutex.Unlock(); } } } void Thread::Sleep(uint ms) { - ASSERT(mImpl); - if (mImpl) + ASSERT(m_Impl); + if (m_Impl) { - mImpl->Sleep(ms); + m_Impl->Sleep(ms); } } void Thread::SetSleepTime(uint ms) { - mSleepTime = ms; + m_SleepTime = ms; } } diff --git a/source/modules/asura-utils/threading/thread.h b/source/modules/asura-utils/threading/thread.h index d365fd0..1de4e33 100644 --- a/source/modules/asura-utils/threading/thread.h +++ b/source/modules/asura-utils/threading/thread.h @@ -151,46 +151,46 @@ namespace AsuraEngine //----------------------------------------------------------------------------// - ThreadImpl* mImpl; + ThreadImpl* m_Impl; - lua_State* mLuaThread; + lua_State* m_LuaThread; /// /// ˴Ƿػģʽ /// - bool mIsDaemon; + bool m_IsDaemon; - std::string mName; - ThreadType mType; - uint mSleepTime; + std::string m_Name; + ThreadType m_Type; + uint m_SleepTime; - ThreadState mState; - Mutex mStateMutex; + ThreadState m_State; + Mutex m_StateMutex; /// /// ͬصź /// - Semaphore mSemPause; - Semaphore mSemResume; - Semaphore mSemStop; + Semaphore m_SemPause; + Semaphore m_SemResume; + Semaphore m_SemStop; /// /// С /// - std::queue<Task*> mTaskQueue; - Mutex mTaskQueueMutex; + std::queue<Task*> m_TaskQueue; + Mutex m_TaskQueueMutex; /// /// ӳģʽʹ /// - std::queue<Task*> mFinishedTasks; - Mutex mFinishedMutex; + std::queue<Task*> m_FinishedTasks; + Mutex m_FinishedMutex; /// /// ģʽʹãصʹõlua߳ /// - lua_State* mCallbackThread; - Luax::LuaxMemberRef mCallbackThreadRef; + lua_State* m_CallbackThread; + Luax::LuaxMemberRef m_CallbackThreadRef; }; diff --git a/source/modules/asura-utils/threading/thread_impl_win32.cpp b/source/modules/asura-utils/threading/thread_impl_win32.cpp index 0e1569c..61b1c13 100644 --- a/source/modules/asura-utils/threading/thread_impl_win32.cpp +++ b/source/modules/asura-utils/threading/thread_impl_win32.cpp @@ -22,15 +22,15 @@ namespace AsuraEngine ThreadImplWin32::~ThreadImplWin32() { - if (!mHandle) return; - ::CloseHandle(mHandle); - mHandle = 0; + if (!m_Handle) return; + ::CloseHandle(m_Handle); + m_Handle = 0; } bool ThreadImplWin32::Start(Threadable* thread, uint32 stacksize/*=0*/) { assert(!IsRunning()); - mHandle = ::CreateThread( + m_Handle = ::CreateThread( NULL , stacksize , _thread_win32_runner @@ -38,18 +38,18 @@ namespace AsuraEngine , 0 /*е*/ , NULL); - return mHandle; + return m_Handle; } void ThreadImplWin32::Join() { // ̵߳ȴ̷߳ - ::WaitForSingleObject(mHandle, INFINITE); + ::WaitForSingleObject(m_Handle, INFINITE); } void ThreadImplWin32::Kill() { - ::TerminateThread(mHandle, FALSE); + ::TerminateThread(m_Handle, FALSE); } void ThreadImplWin32::Sleep(uint ms) @@ -59,10 +59,10 @@ namespace AsuraEngine bool ThreadImplWin32::IsRunning() { - if (mHandle) { + if (m_Handle) { DWORD exitCode = 0; // https://blog.csdn.net/yuanmeng567/article/details/19485719 - ::GetExitCodeThread(mHandle, &exitCode); + ::GetExitCodeThread(m_Handle, &exitCode); return exitCode == STILL_ACTIVE; } return false; @@ -70,7 +70,7 @@ namespace AsuraEngine bool ThreadImplWin32::IsCurrent() { - return mHandle == ::GetCurrentThread(); + return m_Handle == ::GetCurrentThread(); } } diff --git a/source/modules/asura-utils/threading/thread_impl_win32.h b/source/modules/asura-utils/threading/thread_impl_win32.h index fdcfc2b..d1b7ae5 100644 --- a/source/modules/asura-utils/threading/thread_impl_win32.h +++ b/source/modules/asura-utils/threading/thread_impl_win32.h @@ -35,7 +35,7 @@ namespace AsuraEngine private: - HANDLE mHandle; + HANDLE m_Handle; }; |