OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::NativeFileLock Class Reference

Public Member Functions

 NativeFileLock (const char *path)
 ~NativeFileLock ()
bool try_lock ()
void unlock ()

Private Attributes

int m_fd

Detailed Description

Constructor & Destructor Documentation

◆ NativeFileLock()

Slic3r::NativeFileLock::NativeFileLock ( const char * path)
inlineexplicit
39 : m_fd(::open(path, O_RDWR | O_CREAT | O_CLOEXEC, 0644))
40 {
41 if (m_fd < 0)
42 throw std::system_error(errno, std::generic_category(), path);
43 }
int m_fd
Definition InstanceLock.cpp:56

References m_fd.

◆ ~NativeFileLock()

Slic3r::NativeFileLock::~NativeFileLock ( )
inline
44{ ::close(m_fd); }

References m_fd.

Member Function Documentation

◆ try_lock()

bool Slic3r::NativeFileLock::try_lock ( )
inline
46 {
47 if (::flock(m_fd, LOCK_EX | LOCK_NB) == 0)
48 return true;
49 // A signal (a child exiting, for one) interrupts the call like any other; the caller polls again.
50 if (errno == EWOULDBLOCK || errno == EINTR)
51 return false;
52 throw std::system_error(errno, std::generic_category(), "flock");
53 }

References m_fd.

◆ unlock()

void Slic3r::NativeFileLock::unlock ( )
inline
54{ ::flock(m_fd, LOCK_UN); }

References m_fd.

Member Data Documentation

◆ m_fd

int Slic3r::NativeFileLock::m_fd
private

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