Skip to content

Commit 9b0c400

Browse files
committed
Complete Rewrite of the Runtime System.
The runtime system has been completely rewritten. Raffiot now manages its thread pool itself. It makes the runtime system much simpler and robust. The Asynchronous API is now much simpler because the "Future" restriction has been lifted.
1 parent 5967d02 commit 9b0c400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2448
-4754
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ docs: opt
2525

2626
opt:
2727
./scripts/opt.sh
28+
2829
env: conda/env.yml
2930
conda env remove -n raffiot -y
3031
conda env create -f conda/env.yml

demos/dependency_injection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get(self, path: str) -> IO[None, NotFound, str]:
4646
return io.defer(print, f"Opening file {url}").then(response)
4747

4848

49-
main: IO[Service, NotFound, List[str]] = io.read().flat_map(
49+
main: IO[Service, NotFound, List[str]] = io.read.flat_map(
5050
lambda service: service.get("index.html").flat_map(
5151
lambda x: service.get("index.md").flat_map(
5252
lambda y: io.defer(print, "Result = ", [x, y])

demos/raffiot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def prog(color, name, i) -> IO[None, None, None]:
1515
"""
1616
if i > 0:
1717
return io.defer(print, f"{color}From prog {name}: {i}{reset}").then(
18-
io.yield_(), io.defer_io(prog, color, name, i - 1)
18+
io.yield_, io.defer_io(prog, color, name, i - 1)
1919
)
2020
else:
2121
return io.pure(0)

demos/raffiot_demo.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,26 @@ bgreen = "\u001b[92m"
1111
byellow = "\u001b[93m"
1212
bcyan = "\u001b[96m"
1313
14+
1415
def prog(color, name, i) -> IO[None, None, None]:
1516
"""
1617
Print in `color` every number from `i` to 1.
1718
"""
1819
if i > 0:
19-
return (
20-
io.defer(print, f"{color}From prog {name}: {i}{reset}")
21-
.then(
22-
io.yield_(),
23-
io.defer_io(prog, color, name, i - 1)
24-
)
25-
)
20+
return io.defer(print, f"{color}From prog {name}: {i}{reset}").then(
21+
io.yield_, io.defer_io(prog, color, name, i - 1)
22+
)
2623
else:
2724
return io.pure(0)
2825
29-
#The main IO
26+
27+
# The main IO
3028
main: IO[None, None, None] = (
3129
io.parallel(
32-
prog(bred, "A", 10000),
33-
prog(bgreen, "B", 10000),
34-
prog(byellow, "C", 10000),
35-
prog(bcyan, "D", 10000),
30+
prog(bred, "A", 100000),
31+
prog(bgreen, "B", 100000),
32+
prog(byellow, "C", 100000),
33+
prog(bcyan, "D", 100000),
3634
)
3735
.flat_map(lambda fibers: io.wait(fibers))
3836
.then(io.defer(print, "finished"))

docs/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797

9898
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
9999
<div class="sidebar-scrollbox">
100-
<ol class="chapter"><li class="chapter-item expanded "><a href="raffiot.html"><strong aria-hidden="true">1.</strong> Robust and Fast Functional IO Toolkit</a></li><li class="chapter-item expanded "><a href="first_steps.html"><strong aria-hidden="true">2.</strong> First Steps with IO</a></li><li class="chapter-item expanded "><a href="failures.html"><strong aria-hidden="true">3.</strong> Failures</a></li><li class="chapter-item expanded "><a href="context.html"><strong aria-hidden="true">4.</strong> Context</a></li><li class="chapter-item expanded "><a href="lists.html"><strong aria-hidden="true">5.</strong> Combining a list of IOs</a></li><li class="chapter-item expanded "><a href="async.html"><strong aria-hidden="true">6.</strong> Asynchronous Computing</a></li><li class="chapter-item expanded "><a href="resource.html"><strong aria-hidden="true">7.</strong> Resource Management</a></li></ol>
100+
<ol class="chapter"><li class="chapter-item expanded "><a href="raffiot.html"><strong aria-hidden="true">1.</strong> Robust and Fast Functional IO Toolkit</a></li><li class="chapter-item expanded "><a href="first_steps.html"><strong aria-hidden="true">2.</strong> First Steps with IO</a></li><li class="chapter-item expanded "><a href="failures.html"><strong aria-hidden="true">3.</strong> Failures</a></li><li class="chapter-item expanded "><a href="context.html"><strong aria-hidden="true">4.</strong> Context</a></li><li class="chapter-item expanded "><a href="lists.html"><strong aria-hidden="true">5.</strong> Combining a list of IOs</a></li><li class="chapter-item expanded "><a href="async.html"><strong aria-hidden="true">6.</strong> Concurrent Programming</a></li><li class="chapter-item expanded "><a href="resource.html"><strong aria-hidden="true">7.</strong> Resource Management</a></li></ol>
101101
</div>
102102
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
103103
</nav>

docs/api/index.html

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,30 @@ <h1 class="title">Package <code>raffiot</code></h1>
2828
</summary>
2929
<pre><code class="python">from dataclasses import dataclass
3030

31+
from typing_extensions import final
32+
3133
__all__ = [
32-
&#34;_MatchError&#34;,
34+
&#34;MatchError&#34;,
3335
]
3436

3537

38+
@final
3639
@dataclass
37-
class _MatchError(Exception):
40+
class MatchError(Exception):
3841
&#34;&#34;&#34;
3942
Exception for pattern matching errors (used internally, should NEVER happen).
4043
&#34;&#34;&#34;
4144

45+
message: str
46+
47+
48+
@final
49+
@dataclass
50+
class RuntimeFailure(Exception):
51+
&#34;&#34;&#34;
52+
A failure of the Runtime system.
53+
&#34;&#34;&#34;
54+
4255
message: str</code></pre>
4356
</details>
4457
</section>
@@ -58,10 +71,6 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
5871
<dd>
5972
<div class="desc"><p>Data structure to represent the result of computation.</p></div>
6073
</dd>
61-
<dt><code class="name"><a title="raffiot.test" href="test.html">raffiot.test</a></code></dt>
62-
<dd>
63-
<div class="desc"></div>
64-
</dd>
6574
<dt><code class="name"><a title="raffiot.untyped" href="untyped/index.html">raffiot.untyped</a></code></dt>
6675
<dd>
6776
<div class="desc"></div>
@@ -79,8 +88,8 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
7988
<section>
8089
<h2 class="section-title" id="header-classes">Classes</h2>
8190
<dl>
82-
<dt id="raffiot._MatchError"><code class="flex name class">
83-
<span>class <span class="ident">_MatchError</span></span>
91+
<dt id="raffiot.MatchError"><code class="flex name class">
92+
<span>class <span class="ident">MatchError</span></span>
8493
<span>(</span><span>message: str)</span>
8594
</code></dt>
8695
<dd>
@@ -89,8 +98,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8998
<summary>
9099
<span>Expand source code</span>
91100
</summary>
92-
<pre><code class="python">@dataclass
93-
class _MatchError(Exception):
101+
<pre><code class="python">@final
102+
@dataclass
103+
class MatchError(Exception):
94104
&#34;&#34;&#34;
95105
Exception for pattern matching errors (used internally, should NEVER happen).
96106
&#34;&#34;&#34;
@@ -104,7 +114,7 @@ <h3>Ancestors</h3>
104114
</ul>
105115
<h3>Class variables</h3>
106116
<dl>
107-
<dt id="raffiot._MatchError.message"><code class="name">var <span class="ident">message</span> : str</code></dt>
117+
<dt id="raffiot.MatchError.message"><code class="name">var <span class="ident">message</span> : str</code></dt>
108118
<dd>
109119
<div class="desc"></div>
110120
</dd>
@@ -124,17 +134,16 @@ <h1>Index</h1>
124134
<li><code><a title="raffiot.io" href="io.html">raffiot.io</a></code></li>
125135
<li><code><a title="raffiot.resource" href="resource.html">raffiot.resource</a></code></li>
126136
<li><code><a title="raffiot.result" href="result.html">raffiot.result</a></code></li>
127-
<li><code><a title="raffiot.test" href="test.html">raffiot.test</a></code></li>
128137
<li><code><a title="raffiot.untyped" href="untyped/index.html">raffiot.untyped</a></code></li>
129138
<li><code><a title="raffiot.val" href="val.html">raffiot.val</a></code></li>
130139
</ul>
131140
</li>
132141
<li><h3><a href="#header-classes">Classes</a></h3>
133142
<ul>
134143
<li>
135-
<h4><code><a title="raffiot._MatchError" href="#raffiot._MatchError">_MatchError</a></code></h4>
144+
<h4><code><a title="raffiot.MatchError" href="#raffiot.MatchError">MatchError</a></code></h4>
136145
<ul class="">
137-
<li><code><a title="raffiot._MatchError.message" href="#raffiot._MatchError.message">message</a></code></li>
146+
<li><code><a title="raffiot.MatchError.message" href="#raffiot.MatchError.message">message</a></code></li>
138147
</ul>
139148
</li>
140149
</ul>

0 commit comments

Comments
 (0)