package mp.code; import java.lang.ref.Cleaner; /** * A class holding utility functions, as well as functions which are specific * to this language's glue and don't necessarily have a counterpart in the * broader CodeMP API. */ public final class Extensions { /** A {@link Cleaner} handling freeing of memory for library objects. */ static final Cleaner CLEANER = Cleaner.create(); /** * Hashes the given {@link String} using CodeMP's hashing algorithm (xxh3). * @param input the string to hash * @return the hash */ public static native long hash(String input); /** * Drive the underlying library's asynchronous event loop. In other words, tells * it what thread to use. You usually want to call this during initialisation. *
* Passing false will have the native library manage threads, but it may fail to * work with some more advanced features. *
* You may alternatively call this with true, in a separate and dedicated Java thread; * it will remain active in the background and act as event loop. Assign it like this: *
new Thread(() -> Extensions.drive(true)).start();