Skip to content

Commit

Permalink
basic docs for some mainthread module APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
psifertex committed Dec 1, 2023
1 parent d40ab66 commit f1d9742
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/mainthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@


def execute_on_main_thread(func):
"""
The ``execute_on_main_thread`` function takes a single parameter which is a function that will be executed
on the main Binary Ninja thread.
.. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI.
"""
action = scriptingprovider._ThreadActionContext(func)
obj = core.BNExecuteOnMainThread(0, action.callback)
if obj:
Expand All @@ -33,6 +39,12 @@ def execute_on_main_thread(func):


def execute_on_main_thread_and_wait(func):
"""
The ``execute_on_main_thread`` function takes a single parameter which is a function that will be
executed on the main Binary Ninja thread and will block execution of further python until the function returns.
.. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI.
"""
action = scriptingprovider._ThreadActionContext(func)
core.BNExecuteOnMainThreadAndWait(0, action.callback)

Expand All @@ -53,10 +65,19 @@ def worker_interactive_enqueue(func, name=""):


def get_worker_thread_count():
"""
The ``get_worker_thread_count`` function returns the number of worker threads that are currently running.
By default, this is the number of cores on the system minus one, however this can be changed with
``set_worker_thread_count``.
"""
return core.BNGetWorkerThreadCount()


def set_worker_thread_count(count):
"""
The ``set_worker_thread_count`` function sets the number of worker threads that are currently running.
By default, this is the number of cores on the system minus one.
"""
core.BNSetWorkerThreadCount(count)


Expand Down

0 comments on commit f1d9742

Please sign in to comment.