mirror of
https://github.com/silverqx/TinyORM.git
synced 2025-12-30 07:19:34 -06:00
docs added Multi-threading support section
- removed todo task [skip ci]
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user