Skip to content

Commit

Permalink
micropython: Document heap_lock, heap_unlock.
Browse files Browse the repository at this point in the history
Fixes #116
  • Loading branch information
laurensvalk committed Nov 29, 2022
1 parent 1ae0a90 commit 41eb7f4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
12 changes: 8 additions & 4 deletions doc/main/micropython/micropython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

.. autofunction:: micropython.const

.. autofunction:: micropython.opt_level
.. autofunction:: micropython.heap_lock

.. autofunction:: micropython.heap_unlock

.. autofunction:: micropython.kbd_intr

.. autofunction:: micropython.mem_info

.. autofunction:: micropython.qstr_info
.. autofunction:: micropython.opt_level

.. autofunction:: micropython.qstr_info

.. autofunction:: micropython.stack_use

.. autofunction:: micropython.kbd_intr


Examples
---------------------
Expand Down
2 changes: 2 additions & 0 deletions jedi/tests/test_complete_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def test_from_micropython_import():
assert [c["insertText"] for c in completions] == [
"const",
"kbd_intr",
"heap_lock",
"heap_unlock",
"mem_info",
"opt_level",
"qstr_info",
Expand Down
22 changes: 21 additions & 1 deletion src/micropython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,27 @@ def stack_use() -> int:
"""


# REVISIT: Skipping heap lock funcs for now
def heap_lock() -> None:
"""
heap_lock()
Locks the heap. When locked, no memory allocation can occur. A
``MemoryError`` will be raised if any heap allocation is attempted.
"""


def heap_unlock() -> int:
"""
heap_unlock() -> int
Unlocks the heap. Memory allocation is now allowed again.
If :func:`heap_lock()` was called multiple times, :func:`heap_unlock()`
must be called the same number of times to make the heap available again.
Returns:
The lock depth after unlocking. It is ``0`` once it is unlocked.
"""


def kbd_intr(chr: int) -> None:
Expand Down

0 comments on commit 41eb7f4

Please sign in to comment.