Method: SQLite3::Database#busy_handler
- Defined in:
- ext/sqlite3/database.c
#busy_handler {|count| ... } ⇒ Object #busy_handler(Class.new{) ⇒ Object
Register a busy handler with this database instance. When a requested resource is busy, this handler will be invoked. If the handler returns false, the operation will be aborted; otherwise, the resource will be requested again.
The handler will be invoked with the name of the resource that was busy, and the number of times it has been retried.
See also the mutually exclusive #busy_timeout.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'ext/sqlite3/database.c', line 313
static VALUE
busy_handler(int argc, VALUE *argv, VALUE self)
{
sqlite3RubyPtr ctx;
VALUE block;
int status;
TypedData_Get_Struct(self, sqlite3Ruby, &database_type, ctx);
REQUIRE_OPEN_DB(ctx);
rb_scan_args(argc, argv, "01", &block);
if (NIL_P(block) && rb_block_given_p()) { block = rb_block_proc(); }
RB_OBJ_WRITE(self, &ctx->busy_handler, block);
status = sqlite3_busy_handler(
ctx->db,
NIL_P(block) ? NULL : rb_sqlite3_busy_handler,
(void *)ctx
);
CHECK(ctx->db, status);
return self;
}
|