/** * call-seq: * busy_handler( db, handler ) -> nil * * Installs a callback to be invoked whenever a request cannot be honored * because a database is busy. The handler should take two parameters: a * string naming the resource that was being accessed, and an integer indicating * how many times the current request has failed due to the resource being busy. * * If the handler returns +false+, the operation will be aborted, with a * SQLite::BusyException being raised. Otherwise, SQLite will attempt to * access the resource again. * * See #busy_timeout for an easier way to manage the common case. */ static VALUE static_api_busy_handler( VALUE module, VALUE db, VALUE handler ) { sqlite *handle; GetDB( handle, db ); if( handler == Qnil ) { sqlite_busy_handler( handle, NULL, NULL ); } else { if( !rb_obj_is_kind_of( handler, rb_cProc ) ) { rb_raise( rb_eArgError, "handler must be a proc" ); } sqlite_busy_handler( handle, static_busy_handler, (void*)handler ); } return Qnil; }