1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
.mle
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
15 * This shelf provides helpers for atomic operations.
20 public final class AtomicShelf
32 * Lock for garbage collection operations.
34 * @return The locking key if locked, otherwise {@code 0} when busy.
38 public static native int gcLock();
41 * Unlocks the garbage collector provided that the previous locking key
44 * @param __key The key that was previously used to lock the garbage
49 public static native void gcUnlock(int __key
);
52 * For constant lock spins, this provides a consistent means of counting
53 * and then potentially fire-spinning or resting depending on the
54 * situation. This may cause a thread to preempt.
56 * On cooperatively tasked systems, this may switch to another thread.
58 * @param __count The number of times the lock has spun.
62 public static native void spinLock(int __count
);
65 * Returns a "unique" atomic tick value. The value returned should be
66 * unique enough but the actual value that is returned should not be used
67 * in any way for comparisons other than equality.
69 * @return The tick value, note that it should not be used for comparisons
70 * other than equality.
74 public static native int tick();