Package: GNAT.Lock_Files

Description

This package contains the necessary routines for using files for the purpose of providing realiable system wide locking capability.

Header

package GNAT.Lock_Files is
 
pragma Preelaborate;

Exceptions

Lock_Error
Exception raised if file cannot be locked

Other Items:

procedure Lock_File
  (Directory      : String;
   Lock_File_Name : String;
   Wait           : Duration := 1.0;
   Retries        : Natural  := Natural'Last);
Create a lock file Lock_File_Name in directory Directory. If the file cannot be locked because someone already owns the lock, this procedure waits Wait seconds and retries at most Retries times. If the file still cannot be locked, Lock_Error is raised. The default is to try every second, almost forever (Natural'Last times).

procedure Lock_File
  (Lock_File_Name : String;
   Wait           : Duration := 1.0;
   Retries        : Natural  := Natural'Last);
See above. The full lock file path is given as one string.

procedure Unlock_File (Directory : String; Lock_File_Name : String);
Unlock a file

procedure Unlock_File (Lock_File_Name : String);
Unlock a file whose full path is given in Lock_File_Name
end GNAT.Lock_Files;