Package ch.bailu.gtk.glib
Klasse StaticPrivate
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.StaticPrivate
- Alle implementierten Schnittstellen:
PointerInterface
A #GStaticPrivate works almost like a #GPrivate, but it has one
significant advantage. It doesn't need to be created at run-time
like a #GPrivate, but can be defined at compile-time. This is
similar to the difference between #GMutex and #GStaticMutex.
Now look at our give_me_next_number() example with #GStaticPrivate:
significant advantage. It doesn't need to be created at run-time
like a #GPrivate, but can be defined at compile-time. This is
similar to the difference between #GMutex and #GStaticMutex.
Now look at our give_me_next_number() example with #GStaticPrivate:
int give_me_next_number () { static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT; int *current_number = g_static_private_get (¤t_number_key); if (!current_number) { current_number = g_new (int, 1); *current_number = 0; g_static_private_set (¤t_number_key, current_number, g_free); } *current_number = calc_next_number (*current_number); return *current_number; }
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
free()
Releases all resources allocated to @private_key.get()
Works like g_private_get() only for a #GStaticPrivate.static ClassHandler
int
void
init()
Initializes @private_key.void
set
(Pointer data, StaticPrivate.OnDestroyNotify notify) Sets the pointer keyed to @private_key for the current thread and
the function @notify to be called with that pointer (%NULL or
non-%NULL), whenever the pointer is set again or whenever the
current thread ends.Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
INDEX
- Siehe auch:
-
-
Konstruktordetails
-
StaticPrivate
-
StaticPrivate
public StaticPrivate()
-
-
Methodendetails
-
getClassHandler
-
getFieldIndex
public int getFieldIndex() -
free
public void free()Releases all resources allocated to @private_key.
You don't have to call this functions for a #GStaticPrivate with an
unbounded lifetime, i.e. objects declared 'static', but if you have
a #GStaticPrivate as a member of a structure and the structure is
freed, you should also free the #GStaticPrivate. -
get
Works like g_private_get() only for a #GStaticPrivate.
This function works even if g_thread_init() has not yet been called.- Gibt zurück:
- the corresponding pointer
-
init
public void init()Initializes @private_key. Alternatively you can initialize it with
%G_STATIC_PRIVATE_INIT. -
set
Sets the pointer keyed to @private_key for the current thread and
the function @notify to be called with that pointer (%NULL or
non-%NULL), whenever the pointer is set again or whenever the
current thread ends.
This function works even if g_thread_init() has not yet been called.
If g_thread_init() is called later, the @data keyed to @private_key
will be inherited only by the main thread, i.e. the one that called
g_thread_init().
@notify is used quite differently from @destructor in g_private_new().- Parameter:
data
- the new pointernotify
- a function to be called with the pointer whenever the current thread ends or sets this pointer again
-