This file is indexed.

/usr/include/bobcat/sharedcondition is in libbobcat-dev 4.04.00-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef INCLUDED_BOBCAT_SHAREDCONDITION_
#define INCLUDED_BOBCAT_SHAREDCONDITION_

#include <ios>
#include <condition_variable>
#include <chrono>

#include <bobcat/sharedmutex>
#include <bobcat/sharedmemory>

namespace FBB
{

class SharedCondition
{
    SharedMemory *d_shmem;              // Note: not allocated
    std::streamsize d_offset;

    struct Condition: private SharedMutex
    {
        Condition();

        pthread_cond_t d_cond;
    
        using SharedMutex::lock;
        using SharedMutex::unlock;
        using SharedMutex::mutexPtr;
    };

    struct Data
    {
        std::streamsize offset;
        Condition *condition;
    };

    public:
        SharedCondition();
        ~SharedCondition();

        void lock();

        void notify() noexcept;
        void notifyAll() noexcept;

        std::streamsize offset() const;

        void unlock();

        void wait();

        template <typename Predicate>
        void wait(Predicate pred);                          // 2.f

        template <typename Rep, typename Period>            // 1.f
        std::cv_status wait_for(
                std::chrono::duration<Rep, Period> const &relTime
        );

                                                            // 2.f
        template <typename Rep, typename Period, typename Predicate>
        bool wait_for(
                std::chrono::duration<Rep, Period> const &relTime, 
                Predicate pred
        );

        template <typename Clock, typename Duration>        // 1.f
        std::cv_status wait_until(                      
            std::chrono::time_point<Clock, Duration> const &absTime
        );

                                                            // 2.f
        template <typename Clock, typename Duration, typename Predicate>
        bool wait_until(
            std::chrono::time_point<Clock, Duration> const &absTime, 
            Predicate pred
        );


        static SharedCondition attach(SharedMemory &shmem,
                        std::ios::off_type offset = 0,
                        std::ios::seekdir way = std::ios::beg);

        static SharedCondition create(SharedMemory &shmem);

        static constexpr size_t size();

    private:
        SharedCondition(SharedMemory &shmem, std::streamsize offset);
        std::cv_status waiter(Condition *cond, int64_t count);

        Data prepare();
};

inline std::streamsize SharedCondition::offset() const
{
    return d_offset;
}
template <typename Predicate>
void SharedCondition::wait(Predicate pred)
{
    Data data = prepare();
    while (not pred())
        pthread_cond_wait(&(data.condition->d_cond), 
                          data.condition->mutexPtr());
    d_shmem->seek(data.offset);
}
template <typename Rep, typename Period>
inline std::cv_status SharedCondition::wait_for(
            std::chrono::duration<Rep, Period> const &relTime)
{
    return wait_until(std::chrono::system_clock::now() + relTime);
}
template <typename Rep, typename Period, typename Predicate>
inline bool SharedCondition::wait_for(
            std::chrono::duration<Rep, Period> const &relTime, 
            Predicate pred)
{
    return wait_until(std::chrono::system_clock::now() + relTime, pred);
}
template <typename Clock, typename Duration> 
std::cv_status SharedCondition::wait_until(                      
    std::chrono::time_point<Clock, Duration> const &absTime)
{
    Data data = prepare();

    auto ret = waiter(data.condition, absTime.time_since_epoch().count());
    d_shmem->seek(data.offset);
    return ret;
}
template <typename Clock, typename Duration, typename Predicate> 
bool SharedCondition::wait_until(                      
    std::chrono::time_point<Clock, Duration> const &absTime, Predicate pred)
{
    Data data = prepare();

    bool ret = true;

    while (not pred())
    {
        if (waiter(data.condition, absTime.time_since_epoch().count()) 
            == std::cv_status::timeout
        )
        {
            ret = pred();
            break;
        }
    }

    d_shmem->seek(data.offset);
    return ret;
}
constexpr size_t SharedCondition::size()
{
    return sizeof(Condition);
}

} // FBB        
#endif