Skip to content

Commit

Permalink
Function renaming and documentation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer committed Sep 13, 2022
1 parent 435edce commit ed868fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
28 changes: 20 additions & 8 deletions src/napari_imagej/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
A module encapsulating access to Java functionality.
Notable functions included in the module:
* ij()
- used to access the ImageJ instance
* ij_init()
- used to begin the creation of the ImageJ instance.
* ensure_jvm_started()
- used to block execution until the ImageJ instance is ready
* jvm_is_headless()
- reports whether the JVM is being run headlessly
* ij()
- used to access the ImageJ instance
* log_debug()
- used for logging in a standardized way
Expand Down Expand Up @@ -35,14 +35,14 @@ def ij():
Returns the ImageJ instance.
If it isn't ready yet, blocks until it is ready.
"""
return imagej_init().get()
return ij_init().get()


def ensure_jvm_started() -> None:
"""
Blocks until the ImageJ instance is ready.
"""
imagej_init().wait()
ij_init().wait()


def _imagej_init():
Expand Down Expand Up @@ -76,8 +76,20 @@ def _imagej_init():
_ij_future: AsyncResult = None


def imagej_init() -> AsyncResult:
"""Function that"""
def ij_init() -> AsyncResult:
"""
Initializes the singular ImageJ2 instance.
This function returns BEFORE the ImageJ2 instance has been created!
To block until the ImageJ2 instance is ready, use ij() instead.
This function will only create ONE ImageJ2 instance. This ImageJ2 instance
will be created in the first call to this function. Later calls to the function
will return the same AsyncResult generated from the first call to the function.
This function also tries to be thread-safe.
:return: An AsyncResult that will be populated with the ImageJ2
instance once it has been created.
"""
global _ij_future
if not _ij_future:
with init_lock:
Expand Down
4 changes: 2 additions & 2 deletions src/napari_imagej/widgets/napari_imagej.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from napari import Viewer
from qtpy.QtWidgets import QTreeWidgetItem, QVBoxLayout, QWidget

from napari_imagej.java import imagej_init
from napari_imagej.java import ij_init
from napari_imagej.widgets.menu import NapariImageJMenu
from napari_imagej.widgets.result_runner import ResultRunner
from napari_imagej.widgets.result_tree import SearchResultTree, SearchResultTreeItem
Expand All @@ -22,7 +22,7 @@ def __init__(self, napari_viewer: Viewer):
self.setLayout(QVBoxLayout())

# First things first, let's start up imagej (in the background)
imagej_init()
ij_init()

# -- NapariImageJWidget construction -- #

Expand Down

0 comments on commit ed868fc

Please sign in to comment.