Метод acquireTemplateLock
Сигнатура метода
public function acquireTemplateLock(int $templateId): ?ManagedAgentIdentity
Возвращает:
?ManagedAgentIdentity
Описание
Takes the logical lock of the template of a managed copy up front, so that a producer writing several rows inside one transaction takes it once for the whole batch instead of once per row: every registration of that batch then sees the lock as held and asks the database for nothing. The batch therefore writes its rows under one lock, and the state of the instance cannot change between them. What this does not promise is a wait that holds no row locks: on the production path the producer runs inside a transaction its caller has already opened - the ORM events of a template save - so that transaction may hold row locks of its own before this method is reached. What is still gained there is the absence of a lock request between the writes of the batch; the wait before no row locks at all happens only when the producer is called outside a transaction. Unlike {@see self::enterOperation()} this opens no operation scope: the barrier of an enabling instance keeps refusing a producer that does not belong to the operation of the orchestrator. Answers the identity the lock was taken for, or null when there is nothing to lock, when the request holds the lock already, or when the lock could not be taken - the registration of the resource then answers the conflict on its own, exactly as it does without this call. {@see self::releaseTemplateLock()} belongs to the finally block of the caller.
Параметры
1| Имя | Тип | По умолчанию | Флаги |
|---|---|---|---|
$templateId
|
int
|
—
|
—
|
Расположение
Исходный файл метода в Bitrix Framework
~/bitrix/modulesbizproc/lib/Internal/AiAgent/Lifecycle/Service/ManagedAgentResourceRegistry.php