Async And Pooling #202
-
How would promote_to_send and such work across threads for a connection. If I were to say create a single connection and multiple threads tried to use this connection. Of course, I would place this behind a Mutex, but I was wondering if that is necessary or how would it function if it was a RWlock instead of a Mutex. Since I notice the Connection never needs to be mutable? Also, Markus, do you have a discord/telegram account? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes this is necessary. It actually depends on the capabilities of the driver and runtime configuration wether this is safe at all. Yet independent even of that it is not possible to assure the right diagnostics and up at the right thread without an encapsulating mutex.
More advisable than what? Probably not getting that question right. Personally I would create a new connection for each thread that needs one. Using the odbc-api innate connection pooling.
This is just FYI: The ODBC - C API his innate async capabilieties. Two different kinds actually. So at one point this crate may get an
Never used any of these services. Cheers, Markus |
Beta Was this translation helpful? Give feedback.
-
thank you for the quick reply Markus. yeah mostly I am building around what exists and when you do decide to put in async i can just update any code to match it or depreciate those library's at that time in place of using this directly then. I will go with creating a new connection each time versus making a few connections and passing them on. generally that is what my question was about XD. but yeah thank you. |
Beta Was this translation helpful? Give feedback.
Yes this is necessary. It actually depends on the capabilities of the driver and runtime configuration wether this is safe at all. Yet independent even of that it is not possible to assure the right diagnostics and up at the right thread without an encapsulating mutex.
mut
is a misleading keyword. It actually means exclusive. There is plenty of mutation in the connection, but it must be able to be shared by several statements. The safeness of this in a multithreaded scenario depends on the odbc driver correctly protecting its internal state with a mutex. …