aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/vespa/log/lock.h
blob: 2d20f54448601b5823995563bf334948b165debc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <sys/types.h>
#include <fcntl.h>
#include <limits.h>

namespace ns_log {

class Lock {
private:
    Lock();
    Lock(const Lock &);
    Lock& operator =(const Lock &);
    int _fd;
    bool _isLocked;


public:
    int fd() const { return _fd; }
    int size();
    explicit Lock(const char *filename, int mode = O_RDONLY | O_NOCTTY);
    explicit Lock(int fd);
    ~Lock();
    void lock(bool isExclusive);
    void unlock();
};


} // end namespace ns_log