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

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

Initial release

File size: 3.2 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.Private;
22
23private import gi.glib;
24public  import gi.glibtypes;
25
26
27/**
28 * The #GPrivate struct is an opaque data structure to represent a
29 * thread-local data key. It is approximately equivalent to the
30 * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
31 * TlsSetValue()/TlsGetValue() on Windows.
32 *
33 * If you don't already know why you might want this functionality,
34 * then you probably don't need it.
35 *
36 * #GPrivate is a very limited resource (as far as 128 per program,
37 * shared between all libraries). It is also not possible to destroy a
38 * #GPrivate after it has been used. As such, it is only ever acceptable
39 * to use #GPrivate in static scope, and even then sparingly so.
40 *
41 * See G_PRIVATE_INIT() for a couple of examples.
42 *
43 * The #GPrivate structure should be considered opaque.  It should only
44 * be accessed via the g_private_ functions.
45 */
46public class Private
47{
48        /** the main Gtk struct */
49        protected GPrivate* gPrivate;
50        protected bool ownedRef;
51
52        /** Get the main Gtk struct */
53        public GPrivate* getPrivateStruct()
54        {
55                return gPrivate;
56        }
57
58        /** the main Gtk struct as a void* */
59        protected void* getStruct()
60        {
61                return cast(void*)gPrivate;
62        }
63
64        /**
65         * Sets our main struct and passes it to the parent class.
66         */
67        public this (GPrivate* gPrivate, bool ownedRef = false)
68        {
69                this.gPrivate = gPrivate;
70                this.ownedRef = ownedRef;
71        }
72
73
74        /**
75         * Returns the current value of the thread local variable @key.
76         *
77         * If the value has not yet been set in this thread, %NULL is returned.
78         * Values are never copied between threads (when a new thread is
79         * created, for example).
80         *
81         * Returns: the thread-local value
82         */
83        public void* get()
84        {
85                return g_private_get(gPrivate);
86        }
87
88        /**
89         * Sets the thread local variable @key to have the value @value in the
90         * current thread.
91         *
92         * This function differs from g_private_set() in the following way: if
93         * the previous value was non-%NULL then the #GDestroyNotify handler for
94         * @key is run on it.
95         *
96         * Params:
97         *     value = the new value
98         *
99         * Since: 2.32
100         */
101        public void replace(void* value)
102        {
103                g_private_replace(gPrivate, value);
104        }
105
106        /**
107         * Sets the thread local variable @key to have the value @value in the
108         * current thread.
109         *
110         * This function differs from g_private_replace() in the following way:
111         * the #GDestroyNotify for @key is not called on the old value.
112         *
113         * Params:
114         *     value = the new value
115         */
116        public void set(void* value)
117        {
118                g_private_set(gPrivate, value);
119        }
120}
Note: See TracBrowser for help on using the repository browser.