Skip to content

Commit 230fe30

Browse files
edit docs
1 parent 1f59627 commit 230fe30

File tree

7 files changed

+73
-50
lines changed

7 files changed

+73
-50
lines changed

sphinx/box.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
===
2+
Box
3+
===
4+
5+
.. automodule:: asyncgui_ext.synctools.box
6+
:members:
7+
:undoc-members:
8+
:exclude-members:

sphinx/event.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=====
2+
Event
3+
=====
4+
5+
.. automodule:: asyncgui_ext.synctools.event
6+
:members:
7+
:undoc-members:
8+
:exclude-members:

sphinx/index.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ Inter-task sychronization and communication.
77
.. toctree::
88
:hidden:
99

10-
reference
10+
box
11+
event
12+
queue

sphinx/queue.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=====
2+
Queue
3+
=====
4+
5+
.. automodule:: asyncgui_ext.synctools.queue
6+
:members:
7+
:undoc-members:
8+
:exclude-members:

sphinx/reference.rst

-9
This file was deleted.

src/asyncgui_ext/synctools/box.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
__all__ = ('Box', )
2-
import types
3-
1+
'''
2+
.. code-block::
43
5-
class Box:
6-
'''
7-
Similar to :class:`asyncgui.AsyncBox`, but this one can handle multiple tasks simultaneously.
8-
This is the closest thing to :class:`asyncio.Event` in this library.
9-
10-
.. code-block::
4+
import asyncgui as ag
5+
from asyncgui_ext.synctools.box import Box
116
12-
async def async_fn(b1, b2):
13-
args, kwargs = await b1.get()
7+
async def async_fn1(box):
8+
for __ in range(10):
9+
args, kwargs = await box.get()
1410
assert args == (1, )
1511
assert kwargs == {'crow': 'raven', }
1612
17-
args, kwargs = await b2.get()
13+
async def async_fn2(box):
14+
for __ in range(10):
15+
args, kwargs = await box.get()
1816
assert args == (2, )
1917
assert kwargs == {'frog': 'toad', }
2018
21-
args, kwargs = await b1.get()
22-
assert args == (1, )
23-
assert kwargs == {'crow': 'raven', }
19+
box = Box()
20+
box.put(1, crow='raven')
21+
ag.start(async_fn1(box))
22+
box.update(2, frog='toad')
23+
ag.start(async_fn2(box))
24+
'''
25+
26+
27+
__all__ = ('Box', )
28+
import types
2429

25-
b1 = Box()
26-
b2 = Box()
27-
b1.put(1, crow='raven')
28-
start(async_fn(b1, b2))
29-
b2.put(2, frog='toad')
30-
'''
3130

31+
class Box:
3232
__slots__ = ('_item', '_waiting_tasks', )
3333

3434
def __init__(self):

src/asyncgui_ext/synctools/event.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
__all__ = ('Event', )
2-
import types
1+
'''
2+
.. code-block::
33
4+
import asyncgui as ag
5+
from asyncgui_ext.synctools.event import Event
46
5-
class Event:
6-
'''
7-
Similar to :class:`asyncgui.AsyncEvent`, but this one can handle multiple tasks simultaneously.
7+
async def async_fn1(e):
8+
args, kwargs = await e.wait()
9+
assert args == (1, )
10+
assert kwargs == {'crow': 'raven', }
811
9-
.. code-block::
12+
args, kwargs = await e.wait()
13+
assert args == (2, )
14+
assert kwargs == {'toad': 'frog', }
1015
11-
async def async_fn(e):
12-
args, kwargs = await e.wait()
13-
assert args == (2, )
14-
assert kwargs == {'crow': 'raven', }
16+
async def async_fn2(e):
17+
args, kwargs = await e.wait()
18+
assert args == (2, )
19+
assert kwargs == {'toad': 'frog', }
1520
16-
args, kwargs = await e.wait()
17-
assert args == (3, )
18-
assert kwargs == {'toad': 'frog', }
21+
e = Event()
22+
ag.start(async_fn1(e))
23+
e.fire(1, crow='raven')
24+
ag.start(async_fn2(e))
25+
e.fire(2, toad='frog')
26+
'''
27+
28+
__all__ = ('Event', )
29+
import types
1930

20-
e = Event()
21-
e.fire(1, crocodile='alligator')
22-
start(async_fn(e))
23-
e.fire(2, crow='raven')
24-
e.fire(3, toad='frog')
25-
'''
2631

32+
class Event:
2733
__slots__ = ('_waiting_tasks', )
2834

2935
def __init__(self):

0 commit comments

Comments
 (0)