1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-12 07:47:12 +01:00

Added options to control the memory allocated for the query queue.

Fixed const-correctness in several methods of the SQLite connection.
This commit is contained in:
Sandu Liviu Catalin 2016-03-23 05:50:58 +02:00
parent 1a312f7e7f
commit 41f5cfe663
3 changed files with 31 additions and 4 deletions

View File

@ -244,6 +244,15 @@ void Connection::CopyToDatabase(const Connection & db)
TakeSnapshot(db.m_Handle); TakeSnapshot(db.m_Handle);
} }
// ------------------------------------------------------------------------------------------------
void Connection::ReserveQueue(Uint32 num)
{
// Validate the handle
Validate();
// Perform the requested operation
m_Handle->mQueue.reserve(m_Handle->mQueue.size() + num);
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Int32 Connection::Flush(Uint32 num) Int32 Connection::Flush(Uint32 num)
{ {

View File

@ -488,20 +488,36 @@ public:
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Remove all queries from the queue without executing them. * Reserve space upfront for the specified amount of queries in the query queue.
*/ */
void ClearQueue() const void ReserveQueue(Uint32 num);
/* --------------------------------------------------------------------------------------------
* Release memory that is not occupied from the query queue.
*/
void CompactQueue()
{ {
// Validate the handle // Validate the handle
Validate(); Validate();
// Return the requested information // Perform the requested operation
m_Handle->mQueue.shrink_to_fit();
}
/* --------------------------------------------------------------------------------------------
* Remove all queries from the queue without executing them.
*/
void ClearQueue()
{
// Validate the handle
Validate();
// Perform the requested operation
m_Handle->mQueue.clear(); m_Handle->mQueue.clear();
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Remove the last query from the queue. * Remove the last query from the queue.
*/ */
void PopQueue() const void PopQueue()
{ {
// Validate the handle // Validate the handle
Validate(); Validate();

View File

@ -217,6 +217,8 @@ void RegisterAPI(HSQUIRRELVM vm)
.Overload< Int32 (Connection::*)(Int32) >(_SC("GetInfo"), &Connection::GetInfo) .Overload< Int32 (Connection::*)(Int32) >(_SC("GetInfo"), &Connection::GetInfo)
.Overload< Int32 (Connection::*)(Int32, bool) >(_SC("GetInfo"), &Connection::GetInfo) .Overload< Int32 (Connection::*)(Int32, bool) >(_SC("GetInfo"), &Connection::GetInfo)
.Overload< Int32 (Connection::*)(Int32, bool, bool) >(_SC("GetInfo"), &Connection::GetInfo) .Overload< Int32 (Connection::*)(Int32, bool, bool) >(_SC("GetInfo"), &Connection::GetInfo)
.Func(_SC("ReserveQueue"), &Connection::ReserveQueue)
.Func(_SC("CompactQueue"), &Connection::CompactQueue)
.Func(_SC("ClearQueue"), &Connection::ClearQueue) .Func(_SC("ClearQueue"), &Connection::ClearQueue)
.Func(_SC("PopQueue"), &Connection::PopQueue) .Func(_SC("PopQueue"), &Connection::PopQueue)
.Overload< Int32 (Connection::*)(void) >(_SC("Flush"), &Connection::Flush) .Overload< Int32 (Connection::*)(void) >(_SC("Flush"), &Connection::Flush)