Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
Arc::FileLock Class Reference

#include <FileLock.h>

Collaboration diagram for Arc::FileLock:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileLock (const std::string &filename)
 ~FileLock ()
 operator bool ()
bool operator! ()

Private Attributes

const std::string lockfile
int fd

Detailed Description

Definition at line 10 of file FileLock.h.


Constructor & Destructor Documentation

Arc::FileLock::FileLock ( const std::string &  filename)

Definition at line 21 of file FileLock.cpp.

    : lockfile(filename + ".lock") {

    fd = open(lockfile.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
    while ((fd == -1) && (errno == EEXIST)) {
      if (fd != -1)
        close(fd);
      Glib::usleep(10000);
      fd = open(lockfile.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
    }
    if (fd != -1)
      close(fd);
  }

Definition at line 35 of file FileLock.cpp.

                      {
    unlink(lockfile.c_str());
  }

Member Function Documentation

Arc::FileLock::operator bool ( void  )

Definition at line 39 of file FileLock.cpp.

                          {
    return (fd != -1);
  }
bool Arc::FileLock::operator! ( void  )

Definition at line 43 of file FileLock.cpp.

                           {
    return (fd == -1);
  }

Member Data Documentation

int Arc::FileLock::fd [private]

Definition at line 18 of file FileLock.h.

const std::string Arc::FileLock::lockfile [private]

Definition at line 17 of file FileLock.h.


The documentation for this class was generated from the following files: