Platforms to show: All Mac Windows Linux Cross-Platform

Back to MutexMBS class.

MutexMBS.AutoLock as AutoMutexMBS   New in 26.3

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Process MBS Util Plugin 26.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Auto locks the mutex and returns an AutoMutexMBS object to unlock later.
Example
Public Sub test(m as MutexMBS)
// lock count is zero
Var l1 As Integer = m.LockCount

// locks it
Var a As AutoMutexMBS = m.AutoLock

// lock count is 1
Var l2 As Integer = m.LockCount

Break // unlocks when method ends
End Sub

Keep the AutoMutexMBS object in a local variable. When the method ends and the variable is freed, the mutex is unlocked automatically.

MutexMBS.Lock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Process MBS Util Plugin 8.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Locks the mutex.
Example
Var m as new MutexMBS

m.Lock
MsgBox "Got mutex."

m.Unlock
MsgBox "Released mutex."

The function returns as soon as it has access to the mutex.

Always use Lock and Unlock in a pair.

MutexMBS.TryAutoLock as AutoMutexMBS   New in 26.3

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Process MBS Util Plugin 26.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Auto locks the mutex if possible and returns an AutoMutexMBS object to unlock later.

Returns AutoMutexMBS object if we got a lock and nil if not.

Keep the AutoMutexMBS object in a local variable. When the method ends and the variable is freed, the mutex is unlocked automatically.

MutexMBS.TryLock as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Process MBS Util Plugin 10.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Locks the mutex if possible.
Example
Var m as new MutexMBS

if m.TryLock then
MsgBox "Got mutex."

m.Unlock
else
MsgBox "Failed to get mutex."
end if

Returns true if we got a lock and false if not.
Always use Lock and Unlock in a pair.

MutexMBS.Unlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Process MBS Util Plugin 8.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Unlocks the mutex.
Example
Var m as new MutexMBS

m.Lock
MsgBox "Got mutex."

m.Unlock
MsgBox "Released mutex."

Always use Lock and Unlock in a pair.

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...