This file is indexed.

/usr/include/bobcat/semaphore 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
#ifndef INCLUDED_BOBCAT_SEMAPHORE_
#define INCLUDED_BOBCAT_SEMAPHORE_

#include <mutex>
#include <condition_variable>
#include <chrono>

namespace FBB
{

class Semaphore
{
    mutable std::mutex d_mutex;
    std::condition_variable d_condition;
    size_t d_nAvailable;

    public:
        Semaphore(size_t nAvailable);

        template <typename Fun, typename ...Params>
        bool wait(Fun fun, Params &&...args);        // wait # available

        void wait();        // wait # available
                                        
                            // wait for duration timeunits
        template <typename Rep, typename Period>
        std::cv_status wait_for(std::chrono::duration<Rep, Period> 
                                                            const &relTime);

                            // wait until abs. time has been reached
        template <typename Clock, typename Duration>  
        std::cv_status wait_until(std::chrono::time_point<Clock, Duration> 
                                                            const &absTime);

        void notify();      // notify a single waiting thread if initially 0
        void notify_all();  // notify_all # available, notify if initially 0

        void set(size_t available = 0);
        size_t size() const;
};

inline size_t  Semaphore::size() const
{
    return d_nAvailable;
}
template <typename Rep, typename Period>
std::cv_status Semaphore::wait_for(
                        std::chrono::duration<Rep, Period> const &relTime)
{
    std::unique_lock<std::mutex> lk(d_mutex);   // get the lock
    while (d_nAvailable == 0)
        if (d_condition.wait_for(lk, relTime) == std::cv_status::timeout)
            return std::cv_status::timeout;

    --d_nAvailable;
    return std::cv_status::no_timeout;
}
template <typename Clock, typename Duration>  // wait until abs. time
std::cv_status Semaphore::wait_until(std::chrono::time_point<Clock, Duration> 
                                     const &absTime) 
{
    std::unique_lock<std::mutex> lk(d_mutex);   // get the lock
    while (d_nAvailable == 0)
        if (d_condition.wait_until(lk, absTime) == std::cv_status::timeout)
            return std::cv_status::timeout;

    --d_nAvailable;
    return std::cv_status::no_timeout;
}
template <typename Fun, typename ...Params>
bool Semaphore::wait(Fun fun, Params &&...args)
{
    std::unique_lock<std::mutex> lk(d_mutex);   // get the lock
    while (d_nAvailable == 0)
    {
        d_condition.wait(lk);   // see 'wait.cc' 
                                                    // called on notifications
        if (not fun(std::forward<Params>(args)...))
            return false;
    }
    --d_nAvailable;              // dec. semaphore
    return true;
}



}   // FBB

#endif