PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.

Prev | Next | Users Guide | PhantomScript Reference | P1 Systems


Process Control

CloseMutex

Syntax

CloseMutex MutexName=<name>

Description

Closes a mutex

Parameters

<name>

The name of the mutex to close.

Remarks

A mutex is a synchronization mechanism designed to ensure mutually exclusive access to a single resource shared among a set of cooperating processes. A mutex is created when the first process names it in a WaitForMutex statement. Thereafter, other processes naming the mutex access the one created by the first process. If WaitForMutex succeeds (i.e. does not time out), then the calling process "owns" the mutex and no other WaitForMutex requests on that mutex will return sucess until the owning process releases it using the ReleaseMutex statement. A mutex should be closed using CloseMutex when the script has no plans to use it again.

Example

          CloseMutex MutexName="FileAccess" Timeout=60
If Not TimedOut Then
LoadFile buffer "SharedFile.dat"
... change file contents ...
SaveFile "SharedFile.dat" buffer
CloseMutex MutexName="FileAccess"
Else
... perform error actions ...
Endif
... all done ...
CloseMutex MutexName="FileAccess"

The example allows cooperating processes to arrange that one and only one of the process has access to the file SharedFile.dat at a time by synchronizing on the FileAccess mutex.



Prev | Next | Users Guide | PhantomScript Reference | P1 Systems

PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.