Skip to content

Commit

Permalink
Merge pull request rusqlite#854 from mqudsi/document_default_busy_han…
Browse files Browse the repository at this point in the history
…dler

Improve busy handler documentation
  • Loading branch information
gwenn committed Dec 3, 2020
2 parents e75a5a6 + 73754bb commit 4b9e693
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/busy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ impl Connection {
/// connection at any given moment. If another busy handler was defined
/// (using [`busy_handler`](Connection::busy_handler)) prior to calling this routine, that other
/// 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<()> {
let ms: i32 = timeout
.as_secs()
Expand All @@ -33,8 +36,8 @@ impl Connection {

/// Register a callback to handle `SQLITE_BUSY` errors.
///
/// If the busy callback is `None`, then `SQLITE_BUSY is returned
/// immediately upon encountering the lock.` The argument to the busy
/// If the busy callback is `None`, then `SQLITE_BUSY` is returned
/// immediately upon encountering the lock. The argument to the busy
/// handler callback is the number of times that the
/// busy handler has been invoked previously for the
/// same locking event. If the busy callback returns `false`, then no
Expand All @@ -48,6 +51,9 @@ impl Connection {
/// handler. Note that calling [`busy_timeout()`](Connection::busy_timeout) or evaluating `PRAGMA
/// busy_timeout=N` will change the busy handler and thus
/// 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<()> {
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);
Expand Down

0 comments on commit 4b9e693

Please sign in to comment.