The Battle for Wesnoth  1.15.6+dev
concurrency.hpp
Go to the documentation of this file.
1 //
2 // M A R I A D B + +
3 //
4 // Copyright Sylvain Rochette Langlois 2013,
5 // Frantisek Boranek 2015,
6 // The ViaDuck Project 2016 - 2018.
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 
11 #ifndef _MARIADB_CONCURRENCY_HPP_
12 #define _MARIADB_CONCURRENCY_HPP_
13 
14 #include <vector>
15 #include <mariadb++/account.hpp>
16 #include <mariadb++/statement.hpp>
17 
18 namespace mariadb {
19 namespace concurrency {
20  namespace status {
22  }
23 
24  //
25  // Set account for connection
26  //
27  extern void set_account(account_ref& account);
28 
29  //
30  // Query status
31  //
33 
34  //
35  // Execute a query
36  // Note: the void overloads are needed because it was too easy to "forget" passing keep_handle
37  // and getting an invalid handle, instead we now return void when no handle is needed
38  //
39  extern handle execute(const std::string& query, bool keep_handle);
40  inline void execute(const std::string& squery) { execute(squery, false); }
41 
42  extern handle insert(const std::string& query, bool keep_handle);
43  inline void insert(const std::string& squery) { insert(squery, false); }
44 
45  extern handle query(const std::string& query, bool keep_handle);
46  inline void query(const std::string& squery) { query(squery, false); }
47 
48  //
49  // Execute a query using a statement
50  // Note: the void overloads are needed because it was too easy to "forget" passing keep_handle
51  // and getting an invalid handle, instead we now return void when no handle is needed
52  //
53  extern statement_ref create_statement(const std::string& query);
54  extern handle execute(statement_ref& statement, bool keep_handle);
55  inline void execute(statement_ref& statement) { execute(statement, false); }
56 
57  extern handle insert(statement_ref& statement, bool keep_handle);
58  inline void insert(statement_ref& statement) { insert(statement, false); }
59 
60  extern handle query(statement_ref& statement, bool keep_handle);
61  inline void query(statement_ref& statement) { query(statement, false); }
62 
63  //
64  // Query executed, result ready to be used
65  //
66  extern u64 get_execute_result(handle h);
67  extern u64 get_insert_result(handle h);
69 
70  //
71  // Remove a query
72  //
73  // Please note, if a result_set is used, it must be done after the result_set is used...
74  //
75  extern void release_handle(handle h);
76 
77  //
78  // Wait for a handle to signal
79  //
80  extern bool wait_handle(handle h, u64 wait_time_ms = 100);
81 }
82 }
83 
84 #endif
void set_account(account_ref &account)
std::shared_ptr< result_set > result_set_ref
Definition: result_set.hpp:219
std::shared_ptr< account > account_ref
Definition: account.hpp:19
handle query(const std::string &query, bool keep_handle)
#define h
Class used to store account and connection information used by mariadb::connection when connecting...
Definition: account.hpp:46
handle execute(const std::string &query, bool keep_handle)
result_set_ref get_query_result(handle h)
u64 handle
Definition: types.hpp:38
Class representing a prepared statement with binding functionality.
Definition: statement.hpp:39
statement_ref create_statement(const std::string &query)
handle insert(const std::string &query, bool keep_handle)
bool wait_handle(handle h, u64 wait_time_ms=100)
u64 get_insert_result(handle h)
unsigned long long u64
Definition: types.hpp:34
void release_handle(handle h)
u64 get_execute_result(handle h)
std::shared_ptr< statement > statement_ref
Definition: statement.hpp:109
status::type worker_status(handle h)