build_lock_t Derived Type

type, public :: build_lock_t

Lock on a build directory, held by the command that works on it. Release it on every way out of the command, before an error stop too. Do not copy a held lock: both copies would release it.


Finalization Procedures

final :: release_on_exit

  • private subroutine release_on_exit(self)

    Release the lock when it goes out of scope, as on a return from the command that holds it. Compilers that do not finalize local variables, like gfortran before 13, skip this, so commands release the lock themselves as well.

    Arguments

    Type IntentOptional Attributes Name
    type(build_lock_t), intent(inout) :: self

Type-Bound Procedures

procedure, public :: acquire

  • private subroutine acquire(self, build_dir)

    Lock the build directory build_dir, creating it if needed. While another fpm process holds the lock, say so and wait for it. If the lock cannot be taken, warn and go on without it. Does nothing if this lock is already held.

    Arguments

    Type IntentOptional Attributes Name
    class(build_lock_t), intent(inout) :: self
    character(len=*), intent(in) :: build_dir

procedure, public :: held

  • private function held(self)

    Whether this lock is held

    Arguments

    Type IntentOptional Attributes Name
    class(build_lock_t), intent(in) :: self

    Return Value logical

procedure, public :: release

  • private subroutine release(self)

    Release the lock, if held

    Arguments

    Type IntentOptional Attributes Name
    class(build_lock_t), intent(inout) :: self

Source Code

    type :: build_lock_t
        private
        !> Descriptor of the lock file (its HANDLE on Windows), -1 when not held
        integer(kind=c_intptr_t) :: handle = -1
    contains
        procedure :: acquire
        procedure :: release
        procedure :: held
        final :: release_on_exit
    end type build_lock_t