From 46f23b49d3cd4781b78153b38efed4da6529af98 Mon Sep 17 00:00:00 2001 From: Stephanie Gawroriski Date: Thu, 28 Dec 2023 03:32:46 +0000 Subject: [PATCH] Synchronize and return the resultant pointer. --- .../cc/squirreljme/vm/nanocoat/VirtualSuite.java | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/emulators/nanocoat-vm/src/main/java/cc/squirreljme/vm/nanocoat/VirtualSuite.java b/emulators/nanocoat-vm/src/main/java/cc/squirreljme/vm/nanocoat/VirtualSuite.java index c5065d6319..705b792e83 100644 --- a/emulators/nanocoat-vm/src/main/java/cc/squirreljme/vm/nanocoat/VirtualSuite.java +++ b/emulators/nanocoat-vm/src/main/java/cc/squirreljme/vm/nanocoat/VirtualSuite.java @@ -87,26 +87,30 @@ public final class VirtualSuite @SuppressWarnings("unused") private long __list() { - // Was this determined on a previous run already? - PointerFlatList result = this._libraries; - if (result != null) + synchronized (this) + { + // Was this determined on a previous run already? + PointerFlatList result = this._libraries; + if (result != null) + return result.pointerAddress(); + + // Get the names of libraries that are available. + VMSuiteManager manager = this.manager; + AllocPool pool = this.pool; + String[] libNames = manager.listLibraryNames(); + + // Load every single one, to make it easier to use. + int numLibs = libNames.length; + VirtualLibrary[] virtualLibs = new VirtualLibrary[numLibs]; + for (int i = 0; i < numLibs; i++) + virtualLibs[i] = new VirtualLibrary(pool, + manager.loadLibrary(libNames[i])); + + // Store libraries and give it back to NanoCoat + result = FlatList.fromArray(pool, virtualLibs); + this._libraries = result; return result.pointerAddress(); - - // Get the names of libraries that are available. - VMSuiteManager manager = this.manager; - AllocPool pool = this.pool; - String[] libNames = manager.listLibraryNames(); - - // Load every single one, to make it easier to use. - int numLibs = libNames.length; - VirtualLibrary[] virtualLibs = new VirtualLibrary[numLibs]; - for (int i = 0; i < numLibs; i++) - virtualLibs[i] = new VirtualLibrary(pool, - manager.loadLibrary(libNames[i])); - - // Store libraries and give it - result = FlatList.fromArray(pool, virtualLibs); - throw Debugging.todo(); + } } /** -- 2.11.4.GIT