0

I'm using libmysql in a simple multithreaded app which will run on a uni-core embedded system processor. I read here that the client library is almost thread-safe.

Do I need to serialise my app (say, with a mutex)?

1
  • 2
    you should really read the page you linked. it has all the info. Nov 14, 2014 at 18:36

1 Answer 1

3

Depends on what you're doing. In a simple scenario you'd just link against libmysqlclient_r and make sure you don't share a connection with multiple threads nor execute multiple queries "simultaneously" on a single connection.

Other requirements:

  1. Before creating any threads, call mysql_library_init() to initialise the MySQL library;
  2. On each thread call mysql_thread_init() to initialise thread-specific variables before using any MySQL related functions;
  3. Before destroying a thread, call mysql_thread_end().

If your program is respecting these limitations, MySQL is your friend.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.