Kea  2.3.5-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 
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
InterprocessSyncFileError(const char *file, size_t line, const char *what)
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
InterprocessSyncFile(const std::string &task_name)
Constructor.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
File-based Interprocess Sync Class.
int fd_