Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
e2562a99
Commit
e2562a99
authored
Jan 09, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benchmark fix
parent
06133ae0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
benchmarks/mixed_case.cpp
benchmarks/mixed_case.cpp
+30
-30
No files found.
benchmarks/mixed_case.cpp
View file @
e2562a99
...
...
@@ -201,7 +201,7 @@ void chain_link(actor_ptr next)
(
on
<
atom
(
"token"
),
int
>
()
>>
[
&
](
int
v
)
{
next
->
enqueue
(
nullptr
,
std
::
move
(
last_received
())
);
next
<<
last_received
(
);
if
(
v
==
0
)
{
done
=
true
;
...
...
@@ -211,42 +211,40 @@ void chain_link(actor_ptr next)
.
until
([
&
]()
{
return
done
==
true
;
});
}
void
chain_master
(
actor_ptr
msgcollector
)
void
worker_fun
(
actor_ptr
msgcollector
)
{
auto
worker
=
spawn
([
=
]()
{
actor_ptr
mc
=
msgcollector
;
bool
done
=
false
;
do_receive
(
on
<
atom
(
"calc"
),
uint64_t
>
()
>>
[
&
](
uint64_t
what
)
{
send
(
mc
,
atom
(
"result"
),
factorize
(
what
));
},
on
(
atom
(
"done"
))
>>
[
&
]()
{
done
=
true
;
}
)
.
until
([
&
]()
{
return
done
==
true
;
});
});
auto
new_ring
=
[
&
](
int
ring_size
,
int
initial_token_value
)
->
actor_ptr
{
send
(
worker
,
atom
(
"calc"
),
s_task_n
);
actor_ptr
next
=
self
;
for
(
int
i
=
1
;
i
<
ring_size
;
++
i
)
bool
done
=
false
;
do_receive
(
on
<
atom
(
"calc"
),
uint64_t
>
()
>>
[
&
](
uint64_t
what
)
{
send
(
msgcollector
,
atom
(
"result"
),
factorize
(
what
));
},
on
(
atom
(
"done"
))
>>
[
&
]()
{
next
=
spawn
(
chain_link
,
next
)
;
done
=
true
;
}
send
(
next
,
atom
(
"token"
),
initial_token_value
);
return
next
;
};
)
.
until
([
&
]()
{
return
done
==
true
;
});
}
actor_ptr
new_ring
(
actor_ptr
next
,
int
ring_size
)
{
for
(
int
i
=
1
;
i
<
ring_size
;
++
i
)
next
=
spawn
(
chain_link
,
next
);
return
next
;
}
void
chain_master
(
actor_ptr
msgcollector
)
{
auto
worker
=
spawn
(
worker_fun
,
msgcollector
);
receive
(
on
<
atom
(
"init"
),
int
,
int
,
int
>
()
>>
[
&
](
int
rs
,
int
itv
,
int
n
)
{
int
iteration
=
0
;
auto
next
=
new_ring
(
rs
,
itv
);
auto
next
=
new_ring
(
self
,
rs
);
send
(
next
,
atom
(
"token"
),
itv
);
send
(
worker
,
atom
(
"calc"
),
s_task_n
);
do_receive
(
on
<
atom
(
"token"
),
int
>
()
>>
[
&
](
int
v
)
...
...
@@ -255,7 +253,9 @@ void chain_master(actor_ptr msgcollector)
{
if
(
++
iteration
<
n
)
{
next
=
new_ring
(
rs
,
itv
);
next
=
new_ring
(
self
,
rs
);
send
(
next
,
atom
(
"token"
),
itv
);
send
(
worker
,
atom
(
"calc"
),
s_task_n
);
}
}
else
...
...
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