Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

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