blob: 03844a2fa8ac93bd8a10a9998f57cb73573ebea1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef MYSQL_ASYNC_H
#define MYSQL_ASYNC_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/fasttimer.h"
class IMySQL;
class CQueryResults
{
public:
IMySQLRowSet *m_pResults;
void *m_pUserData; // This is the value passed to Execute.
CCycleCount m_ExecuteTime; // How long it took to execute this query in MySQL.
CCycleCount m_QueueTime; // How long it spent in the queue.
};
// This provides a way to do asynchronous MySQL queries. They are executed in a thread,
// then you can pop the results off as they arrive.
class IMySQLAsync
{
public:
virtual void Release() = 0;
// After finishing the current query, if there is one, this immediately executes
// the specified query and returns its results.
virtual IMySQLRowSet* ExecuteBlocking( const char *pStr ) = 0;
// Queue up a query.
virtual void Execute( const char *pStr, void *pUserData ) = 0;
// Poll this to pick up results from Execute().
// NOTE: if this returns true, but pResults is set to NULL, then that query had an error.
virtual bool GetNextResults( CQueryResults &results ) = 0;
};
// Create an async mysql interface. Note: if this call returns a non-null value,
// then after this call, you do NOT own pSQL anymore and you shouldn't ever call
// a function in it again.
IMySQLAsync* CreateMySQLAsync( IMySQL *pSQL );
#endif // MYSQL_ASYNC_H
|