MySQL Forums
Forum List  »  Connector/C++

Re: How do I get the session state (and then reconnect)?
Posted by: Wh Ooo
Date: June 21, 2021 12:01PM

Okay, thanks. But I have a question about the performance and implementation of low-level code.

Is it the mysqlx::Client or mysqlx::Session that keeps the connection to the server?

If I do this:

std::thread ProcessingThread{ [] ()
mysqlx::ClientSettings settings{ /* my settings */ };
mysqlx::Client client client{ settings };

while (ThreadMessage != Quit) // my quit condition from the processing thread
mysqlx::Session session{ client }; // <<< IS IT OK IF I WILL CREATE A SESSION EVERY TIME???
mysqlx::Schema schema{ session, /* my settings */ };
mysqlx::Table table{ schema, /* my settings */ };

for (auto& query : Queries) // processing a pack of queries
Table.insert(query).execute(); // just for example

ConditionVariable.wait(/* my settings */); // we are waiting for a new pack of queries from another thread (from a few milliseconds to a few days)

Is this going to be OK? If anything, the "ConditionVariable" can wait from a few milliseconds to a few days. And it seems to me that if mysqlx::Session will establish a connection from scratch every time (if this is of course the case) it will be slow.

Thank you again for your answer!

Options: ReplyQuote

Written By
Re: How do I get the session state (and then reconnect)?
June 21, 2021 12:01PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.