aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system/handle_eintr-inl.h
blob: d98c160c6e29111ff8e190cde40e7b1f146c2355 (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
33
34
#ifndef HANDLE_EINTR_INL_H_
#error "Direct inclusion of this file is not allowed, include handle_eintr.h"
// For the sake of sane code completion.
#include "handle_eintr.h"
#endif

#include <errno.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

#ifndef _win_
template <class F,  class... Args>
auto HandleEintr(F f, Args&&... args) -> decltype(f(args...))
{
    while (true) {
        auto x = f(args...);
        if (x != -1 || errno != EINTR) {
            return x;
        }
    }
}
#else
template <class F,  class... Args>
auto HandleEintr(F f, Args&&... args) -> decltype(f(args...))
{
     return f(args...);
}
#endif

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT