File: glib_extra_def_impl.hpp

package info (click to toggle)
cppgir 2.0%2Bgit20240928.c8bb1c6%2Breally2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,228 kB
  • sloc: cpp: 14,307; ansic: 339; makefile: 11; sh: 9
file content (61 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (2)
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
#ifndef _GI_GLIB_GLIB_EXTRA_DEF_IMPL_HPP_
#define _GI_GLIB_GLIB_EXTRA_DEF_IMPL_HPP_

namespace gi
{
namespace repository
{
namespace GLib
{
gi::rv<guint>::type
idle_add(GLib::SourceFunc function) GI_NOEXCEPT_DECL(true)
{
  return idle_add(GLib::PRIORITY_DEFAULT_IDLE_, function);
}

gi::rv<guint>::type
idle_add_once(std::function<void()> function) GI_NOEXCEPT_DECL(true)
{
  // clang-format off
  return idle_add([=] { function(); return false; });
  // clang-format on
}

gi::rv<guint>::type
timeout_add_seconds(guint interval, GLib::SourceFunc function)
    GI_NOEXCEPT_DECL(true)
{
  return timeout_add_seconds(GLib::PRIORITY_DEFAULT_, interval, function);
}

gi::rv<guint>::type
timeout_add_seconds_once(guint interval, std::function<void()> function)
    GI_NOEXCEPT_DECL(true)
{
  // clang-format off
  return timeout_add_seconds(interval, [=] { function(); return false; });
  // clang-format on
}

gi::rv<guint>::type
timeout_add(guint interval, GLib::SourceFunc function) GI_NOEXCEPT_DECL(true)
{
  return timeout_add(GLib::PRIORITY_DEFAULT_, interval, function);
}

gi::rv<guint>::type
timeout_add_once(guint interval, std::function<void()> function)
    GI_NOEXCEPT_DECL(true)
{
  // clang-format off
  return timeout_add(interval, [=] { function(); return false; });
  // clang-format on
}

} // namespace GLib

} // namespace repository

} // namespace gi

#endif