Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
25574882
Commit
25574882
authored
Mar 26, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actor mutex example works
parent
e33bf6d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
11 deletions
+2
-11
typon/include/python/builtins/mutex.hpp
typon/include/python/builtins/mutex.hpp
+0
-5
typon/trans/tests/actor_inc.py
typon/trans/tests/actor_inc.py
+2
-6
No files found.
typon/include/python/builtins/mutex.hpp
View file @
25574882
...
...
@@ -40,15 +40,10 @@ struct TyMutex__oo : classtype<_Base0, TyMutex__oo<>> {
auto
typon
$$
sync
(
auto
,
auto
)
->
TyNone
const
{
return
None
;
}
auto
operator
()(
auto
_self
,
auto
callback
)
->
typon
::
Task
<
TyNone
>
const
{
print
(
"1"
_ps
);
auto
self
=
arc
(
_self
);
print
(
"2"
_ps
);
auto
lock
=
dot
(
self
,
mutex
).
lock
();
print
(
"3"
_ps
);
co_await
lock
;
print
(
"4"
_ps
);
co_await
callback
(
ref
(
dot
(
self
,
cell
)));
print
(
"5"
_ps
);
co_return
None
;
}
}
static
constexpr
when
{};
...
...
typon/trans/tests/actor_inc.py
View file @
25574882
...
...
@@ -10,22 +10,18 @@ class Actor[T]:
return
future
(
lambda
:
self
.
mutex
.
when
(
f
))
def
inc
(
cell
):
print
(
"inc"
)
#
print("inc")
x
=
cell
.
val
sleep
(
1
)
cell
.
val
=
x
+
1
print
(
"current:"
,
cell
.
val
)
def
truc
():
print
(
"a"
)
a
=
Actor
(
0
)
print
(
"b"
)
for
i
in
range
(
10
):
print
(
"spawn"
,
i
)
a
.
when
(
inc
)
print
(
"spawned"
,
i
)
future
=
a
.
when
(
lambda
cell
:
print
(
"final:"
,
cell
.
val
))
#
future.get()
future
.
get
()
print
(
"done"
)
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment