Kea  1.5.0
interprocess_sync_file.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef INTERPROCESS_SYNC_FILE_H
8 #define INTERPROCESS_SYNC_FILE_H
9 
11 #include <exceptions/exceptions.h>
12 
13 namespace isc {
14 namespace log {
15 namespace interprocess {
16 
22 public:
23  InterprocessSyncFileError(const char* file, size_t line,
24  const char* what) :
25  isc::Exception(file, line, what) {}
26 };
27 
43 public:
51  InterprocessSyncFile(const std::string& task_name) :
52  InterprocessSync(task_name), fd_(-1)
53  {}
54 
56  virtual ~InterprocessSyncFile();
57 
58 protected:
63  bool lock();
64 
68  bool tryLock();
69 
73  bool unlock();
74 
75 private:
76  bool do_lock(int cmd, short l_type);
77 
78  int fd_;
79 };
80 
81 } // namespace interprocess
82 } // namespace log
83 } // namespace isc
84 
85 #endif // INTERPROCESS_SYNC_FILE_H
isc::log::interprocess::InterprocessSync
Interprocess Sync Class.
Definition: interprocess_sync.h:38
isc::log::interprocess::InterprocessSyncFileError
InterprocessSyncFileError.
Definition: interprocess_sync_file.h:21
isc::log::interprocess::InterprocessSyncFile::lock
bool lock()
Acquire the lock (blocks if something else has acquired a lock on the same task name)
Definition: interprocess_sync_file.cc:89
isc::log::interprocess::InterprocessSyncFileError::InterprocessSyncFileError
InterprocessSyncFileError(const char *file, size_t line, const char *what)
Definition: interprocess_sync_file.h:23
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::log::interprocess::InterprocessSyncFile::tryLock
bool tryLock()
Try to acquire a lock (doesn't block)
Definition: interprocess_sync_file.cc:103
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
isc::log::interprocess::InterprocessSyncFile
File-based Interprocess Sync Class.
Definition: interprocess_sync_file.h:42
interprocess_sync.h
isc::log::interprocess::InterprocessSyncFile::~InterprocessSyncFile
virtual ~InterprocessSyncFile()
Destructor.
Definition: interprocess_sync_file.cc:31
exceptions.h
isc::log::interprocess::InterprocessSyncFile::unlock
bool unlock()
Release the lock.
Definition: interprocess_sync_file.cc:117
isc::log::interprocess::InterprocessSyncFile::InterprocessSyncFile
InterprocessSyncFile(const std::string &task_name)
Constructor.
Definition: interprocess_sync_file.h:51