diff --git a/.gitignore b/.gitignore index 394cbad..08229a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ example -test/test.o \ No newline at end of file +test/test.o +test/*.test \ No newline at end of file diff --git a/2.test b/2.test new file mode 100644 index 0000000..e69de29 diff --git a/src/mysql.cpp b/src/mysql.cpp index b1ed954..f46b453 100644 --- a/src/mysql.cpp +++ b/src/mysql.cpp @@ -122,6 +122,7 @@ mySQL::mySQL(const string _path, const string _username, const string _password, cout << except << endl; } } + usleep(1000); // za smanjenje zauzeća procesora } return; @@ -297,11 +298,15 @@ void mySQL::getColumns(const string _table, vector &_columns, Connection Connection* mySQL::shift_con() { while (true) { io.lock(); - for (uint i=0; iisValid()) { + io.unlock(); + return con_ptr; + } else { + --i; + } } io.unlock(); } diff --git a/test/test.cpp b/test/test.cpp index 0b019f8..38ee9c7 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -9,9 +9,11 @@ using namespace chrono; int main() { try { - mySQL mydb("tcp://192.168.2.10:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 1); + // mySQL mydb("tcp://192.168.2.10:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 1); + mySQL mydb("tcp://192.168.2.10:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 5); - sleep(3); + // sleep(3600*10); + sleep(30); auto start = high_resolution_clock::now(); @@ -97,28 +99,28 @@ int main() { // t6.join(); // one by one - try { - sqlQA test_qa; - test_qa.select().from("records").where("enabled = 1"); - mydb.exec(test_qa); - test_qa.print(true); - } catch (const string err) { - cout << err << endl; - } + // try { + // sqlQA test_qa; + // test_qa.select().from("records").where("enabled = 1"); + // mydb.exec(test_qa); + // test_qa.print(true); + // } catch (const string err) { + // cout << err << endl; + // } - try { - sqlQA test_qa; - test_qa.select().from("users"); - mydb.exec(test_qa); - test_qa.print(true); - } catch (const string err) { - cout << err << endl; - } + // try { + // sqlQA test_qa; + // test_qa.select().from("users"); + // mydb.exec(test_qa); + // test_qa.print(true); + // } catch (const string err) { + // cout << err << endl; + // } try { sqlQA test_qa; - test_qa.select().from("users"); + test_qa.select("zone_id,record_type,enabled").from("records").where("domain = 'bitelex.test'"); mydb.exec(test_qa); test_qa.print(true); } catch (const string err) { @@ -130,7 +132,7 @@ int main() { auto duration = duration_cast(end - start); cout << "-------------Izvršilo se za: " << (double)(duration.count() / 1000.0) << " ms"<< endl; - sleep(100); + // sleep(100); } catch (const SQLException error) { diff --git a/test/test.o b/test/test.o index 4ca51da..c324384 100755 Binary files a/test/test.o and b/test/test.o differ