source: appstream-generator/build/girepo/glib/Once.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 3.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.Once;
22
23private import gi.glib;
24public  import gi.glibtypes;
25
26
27/**
28 * A #GOnce struct controls a one-time initialization function. Any
29 * one-time initialization function must have its own unique #GOnce
30 * struct.
31 *
32 * Since: 2.4
33 */
34public class Once
35{
36        /** the main Gtk struct */
37        protected GOnce* gOnce;
38        protected bool ownedRef;
39
40        /** Get the main Gtk struct */
41        public GOnce* getOnceStruct()
42        {
43                return gOnce;
44        }
45
46        /** the main Gtk struct as a void* */
47        protected void* getStruct()
48        {
49                return cast(void*)gOnce;
50        }
51
52        /**
53         * Sets our main struct and passes it to the parent class.
54         */
55        public this (GOnce* gOnce, bool ownedRef = false)
56        {
57                this.gOnce = gOnce;
58                this.ownedRef = ownedRef;
59        }
60
61
62        /** */
63        public void* impl(GThreadFunc func, void* arg)
64        {
65                return g_once_impl(gOnce, func, arg);
66        }
67
68        /**
69         * Function to be called when starting a critical initialization
70         * section. The argument @location must point to a static
71         * 0-initialized variable that will be set to a value other than 0 at
72         * the end of the initialization section. In combination with
73         * g_once_init_leave() and the unique address @value_location, it can
74         * be ensured that an initialization section will be executed only once
75         * during a program's life time, and that concurrent threads are
76         * blocked until initialization completed. To be used in constructs
77         * like this:
78         *
79         * |[<!-- language="C" -->
80         * static gsize initialization_value = 0;
81         *
82         * if (g_once_init_enter (&initialization_value))
83         * {
84         * gsize setup_value = 42; // initialization code here
85         *
86         * g_once_init_leave (&initialization_value, setup_value);
87         * }
88         *
89         * // use initialization_value here
90         * ]|
91         *
92         * Params:
93         *     location = location of a static initializable variable containing 0
94         *
95         * Returns: %TRUE if the initialization section should be entered,
96         *     %FALSE and blocks otherwise
97         *
98         * Since: 2.14
99         */
100        public static bool initEnter(void* location)
101        {
102                return g_once_init_enter(location) != 0;
103        }
104
105        /**
106         * Counterpart to g_once_init_enter(). Expects a location of a static
107         * 0-initialized initialization variable, and an initialization value
108         * other than 0. Sets the variable to the initialization value, and
109         * releases concurrent threads blocking in g_once_init_enter() on this
110         * initialization variable.
111         *
112         * Params:
113         *     location = location of a static initializable variable containing 0
114         *     result = new non-0 value for *@value_location
115         *
116         * Since: 2.14
117         */
118        public static void initLeave(void* location, size_t result)
119        {
120                g_once_init_leave(location, result);
121        }
122}
Note: See TracBrowser for help on using the repository browser.