Add vendor API to software math.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / mle / AtomicShelf.java
blobfb411e24bfce87d417d9f968f0fd20ae208b02b5
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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;
14 /**
15 * This shelf provides helpers for atomic operations.
17 * @since 2020/05/30
19 @SquirrelJMEVendorApi
20 public final class AtomicShelf
22 /**
23 * Not used.
25 * @since 2020/05/30
27 private AtomicShelf()
31 /**
32 * Lock for garbage collection operations.
34 * @return The locking key if locked, otherwise {@code 0} when busy.
35 * @since 2020/05/30
37 @SquirrelJMEVendorApi
38 public static native int gcLock();
40 /**
41 * Unlocks the garbage collector provided that the previous locking key
42 * matches.
44 * @param __key The key that was previously used to lock the garbage
45 * collector.
46 * @since 2020/05/30
48 @SquirrelJMEVendorApi
49 public static native void gcUnlock(int __key);
51 /**
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.
59 * @since 2020/05/30
61 @SquirrelJMEVendorApi
62 public static native void spinLock(int __count);
64 /**
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.
71 * @since 2020/05/03
73 @SquirrelJMEVendorApi
74 public static native int tick();