[docs] Document default busy_timeout/busy_handler

Include a note in the documentation for both `busy_handler()` and
`busy_timeout()` explaining the current default behavior (with a
disclaimer indicating that this behavior should not be relied upon as it
is an implementation detail that may change).
This commit is contained in:
Mahmoud Al-Qudsi 2020-12-02 17:10:15 -06:00
parent 2dab6d8364
commit 73754bbe24

View File

@ -21,6 +21,9 @@ impl Connection {
/// connection at any given moment. If another busy handler was defined /// connection at any given moment. If another busy handler was defined
/// (using [`busy_handler`](Connection::busy_handler)) prior to calling this routine, that other /// (using [`busy_handler`](Connection::busy_handler)) prior to calling this routine, that other
/// busy handler is cleared. /// busy handler is cleared.
///
/// Newly created connections currently have a default busy timeout of 5000ms, but this may be
/// subject to change.
pub fn busy_timeout(&self, timeout: Duration) -> Result<()> { pub fn busy_timeout(&self, timeout: Duration) -> Result<()> {
let ms: i32 = timeout let ms: i32 = timeout
.as_secs() .as_secs()
@ -48,6 +51,9 @@ impl Connection {
/// handler. Note that calling [`busy_timeout()`](Connection::busy_timeout) or evaluating `PRAGMA /// handler. Note that calling [`busy_timeout()`](Connection::busy_timeout) or evaluating `PRAGMA
/// busy_timeout=N` will change the busy handler and thus /// busy_timeout=N` will change the busy handler and thus
/// clear any previously set busy handler. /// clear any previously set busy handler.
///
/// Newly created connections default to a [`busy_timeout()`](Connection::busy_timeout) handler
/// with a timeout of 5000ms, although this is subject to change.
pub fn busy_handler(&self, callback: Option<fn(i32) -> bool>) -> Result<()> { pub fn busy_handler(&self, callback: Option<fn(i32) -> bool>) -> Result<()> {
unsafe extern "C" fn busy_handler_callback(p_arg: *mut c_void, count: c_int) -> c_int { unsafe extern "C" fn busy_handler_callback(p_arg: *mut c_void, count: c_int) -> c_int {
let handler_fn: fn(i32) -> bool = mem::transmute(p_arg); let handler_fn: fn(i32) -> bool = mem::transmute(p_arg);