Pooled PostgreSQL Interface for TGEA
Finally finished testing the PGSQL interface for TGEA. The unexpected twist, after two threads on a Quad core machine the throughput actually decreases. With two threads we managed to achieve 1700 queries per second to the database. Not to shabby.
Code:
function GameConnection::sendAvailablePlayers( %client )
{
%db = PGSQLPool::getPool();
%db.Exec(%client, "onPlayerListCallback", "SELECT * FROM players WHERE uid = %x;", %client.uid);
}
function GameConnection::onPlayerListCallback( %client, %r )
{
commandToClient(%client, 'availablePlayers');
%db = PGSQLPool::getPool();
%num = %db.getNumRows(%r);
for (%i = 0; %i < %num; %i++)
{
%pid = %db.getNamedValue(%r,%i,"pid");
%name = %db.getNamedValue(%r,%i,"name");
%class = %db.getNamedValue(%r,%i,"class");
%level = %db.getNamedValue(%r,%i,"level");
if (%pid)
commandToClient(%client, 'sendPlayer', %pid, %name, %class,...
2008-07-03 6:29 AM PDT by
=s5a= ダンニ (animelab)
View entry -
views: 106