MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / acquire

Method acquire

src/jrd/Relation.cpp:521–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521bool jrd_rel::GCExclusive::acquire(int wait)
522{
523 // if validation is already running - go out
524 if (m_relation->rel_flags & REL_gc_disabled)
525 return false;
526
527 ThreadStatusGuard temp_status(m_tdbb);
528
529 m_relation->rel_flags |= REL_gc_disabled;
530
531 int sleeps = -wait * 10;
532 while (m_relation->rel_sweep_count)
533 {
534 EngineCheckout cout(m_tdbb, FB_FUNCTION);
535 Thread::sleep(100);
536
537 if (wait < 0 && --sleeps == 0)
538 break;
539 }
540
541 if (m_relation->rel_sweep_count)
542 {
543 m_relation->rel_flags &= ~REL_gc_disabled;
544 return false;
545 }
546
547 if (!(m_relation->rel_flags & REL_gc_lockneed))
548 {
549 m_relation->rel_flags |= REL_gc_lockneed;
550 LCK_release(m_tdbb, m_relation->rel_gc_lock);
551 }
552
553 // we need no AST here
554 if (!m_lock)
555 m_lock = jrd_rel::createLock(m_tdbb, NULL, m_relation, LCK_rel_gc, true);
556
557 const bool ret = LCK_lock(m_tdbb, m_lock, LCK_PW, wait);
558 if (!ret)
559 m_relation->rel_flags &= ~REL_gc_disabled;
560
561 return ret;
562}
563
564void jrd_rel::GCExclusive::release()
565{

Callers 2

GuardMethod · 0.45
walk_relationMethod · 0.45

Calls 3

LCK_releaseFunction · 0.85
LCK_lockFunction · 0.85
sleepFunction · 0.50

Tested by

no test coverage detected