1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module glib.Private; 26 27 private import gtkc.glib; 28 public import gtkc.glibtypes; 29 30 31 /** 32 * The #GPrivate struct is an opaque data structure to represent a 33 * thread-local data key. It is approximately equivalent to the 34 * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to 35 * TlsSetValue()/TlsGetValue() on Windows. 36 * 37 * If you don't already know why you might want this functionality, 38 * then you probably don't need it. 39 * 40 * #GPrivate is a very limited resource (as far as 128 per program, 41 * shared between all libraries). It is also not possible to destroy a 42 * #GPrivate after it has been used. As such, it is only ever acceptable 43 * to use #GPrivate in static scope, and even then sparingly so. 44 * 45 * See G_PRIVATE_INIT() for a couple of examples. 46 * 47 * The #GPrivate structure should be considered opaque. It should only 48 * be accessed via the g_private_ functions. 49 */ 50 public class Private 51 { 52 /** the main Gtk struct */ 53 protected GPrivate* gPrivate; 54 55 /** Get the main Gtk struct */ 56 public GPrivate* getPrivateStruct() 57 { 58 return gPrivate; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected void* getStruct() 63 { 64 return cast(void*)gPrivate; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GPrivate* gPrivate) 71 { 72 this.gPrivate = gPrivate; 73 } 74 75 76 /** 77 * Returns the current value of the thread local variable @key. 78 * 79 * If the value has not yet been set in this thread, %NULL is returned. 80 * Values are never copied between threads (when a new thread is 81 * created, for example). 82 * 83 * Return: the thread-local value 84 */ 85 public void* get() 86 { 87 return g_private_get(gPrivate); 88 } 89 90 /** 91 * Sets the thread local variable @key to have the value @value in the 92 * current thread. 93 * 94 * This function differs from g_private_set() in the following way: if 95 * the previous value was non-%NULL then the #GDestroyNotify handler for 96 * @key is run on it. 97 * 98 * Params: 99 * value = the new value 100 * 101 * Since: 2.32 102 */ 103 public void replace(void* value) 104 { 105 g_private_replace(gPrivate, value); 106 } 107 108 /** 109 * Sets the thread local variable @key to have the value @value in the 110 * current thread. 111 * 112 * This function differs from g_private_replace() in the following way: 113 * the #GDestroyNotify for @key is not called on the old value. 114 * 115 * Params: 116 * value = the new value 117 */ 118 public void set(void* value) 119 { 120 g_private_set(gPrivate, value); 121 } 122 }