docs added Multi-threading support section

- removed todo task

[skip ci]
This commit is contained in:
silverqx
2022-05-24 11:30:27 +02:00
parent 67628bdc13
commit 7f7dc87c96
2 changed files with 13 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ description: TinyORM makes interacting with a database extremely simple using ra
- [Running SQL Queries](#running-sql-queries)
- [Using Multiple Database Connections](#using-multiple-database-connections)
- [Database Transactions](#database-transactions)
- [Multi-threading support](#multi-threading-support)
## Introduction
@@ -235,3 +236,15 @@ All transaction methods accept a connection name as the optional argument:
:::tip
The `DB` facade's transaction methods control the transactions for both the [query builder](database/query-builder.mdx) and [TinyORM](tinyorm/getting-started.mdx).
:::
## Multi-threading support
The `TinyORM` supports multi-threading for the `MSVC` and `GCC` on Linux compilers. Multi-threading is disabled for the `Clang` compiler on both Linux and MSYS2 and for the `GCC` compiler on MSYS2. The reason are bugs in the `TLS` wrapper that is generated by the [`thread_local`](https://en.cppreference.com/w/cpp/keyword/thread_local) keyword.
A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread where the connection was created is not supported.
In addition, the third party libraries used by the `QSqlDrivers` can impose further restrictions on using the SQL Module in a multithreaded program.
In short, if you create a `DB::connection` in some thread then you have to use this connection only from this particular thread and of course all queries that will be executed on this connection.
If you want to execute some query from another thread for the same connection then you have to create a new connection first and if you have a new connection you can send a query from this new thread to the database.

View File

@@ -1326,7 +1326,6 @@ TINYORM_END_COMMON_NAMESPACE
// CUR export dll paths in Invoke- ps1 scripts, also check dotenv and source if needed and add dotenv example to tools/ silverqx
// TODO cache static_cast<>(*this) in the model()/basemodel() CRTP as a class data member std::optional<std::reference_wrapper<Derived>> m_model = std::nullopt, but I will have to create copy ctor to set m_model {std::nullopt}, the same for other similar model() methods like Model::model(), then I can to check if (m_model) and return right away and I will call static_cast or dynamic_cast only once for every instance, it is casted everytime now 😟 silverqx
// CUR rename USING_PCH to TINY_USING_PCH or TINYORM_USING_PCH/TINYUTILS_USING_PCH? silverqx
// CUR docs threading DB one per whole app, DatabaseConnection has to be used from thread where it was created silverqx
// CUR docs exceptions, which methods throw which exceptions, so user know which exception classes to define in a catch blocks silverqx
// CUR Belongs To Many firstOrNew, firstOrCreate, and updateOrCreate Methods, revisit first and second argument silverqx
// CUR add attribute to touch() method silverqx