| Kea 3.0.2-git

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
10#include <log/interprocess/interprocess_sync.h>
11#include <exceptions/exceptions.h>
12
13 namespace isc {
14 namespace log {
15 namespace interprocess {
16
21 class InterprocessSyncFileError : public Exception {
22 public:
23 InterprocessSyncFileError(const char* file, size_t line,
24 const char* what) :
25 isc::Exception(file, line, what) {}
26};
27
42 class InterprocessSyncFile : public InterprocessSync {
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::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
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::InterprocessSyncFileError::InterprocessSyncFileError
InterprocessSyncFileError(const char *file, size_t line, const char *what)
Definition interprocess_sync_file.h:23
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
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::InterprocessSyncFile::~InterprocessSyncFile
virtual ~InterprocessSyncFile()
Destructor.
Definition interprocess_sync_file.cc:31
isc::log::interprocess::InterprocessSyncFile::tryLock
bool tryLock()
Try to acquire a lock (doesn't block).
Definition interprocess_sync_file.cc:103
isc::log::interprocess::InterprocessSync::InterprocessSync
InterprocessSync(const std::string &task_name)
Constructor.
Definition interprocess_sync.h:52
exceptions.h
interprocess_sync.h
isc::log::interprocess
Definition log/logger.h:25
isc::log
Definition buffer_appender_impl.cc:17
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148