Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libfibre
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zhaocheng Che
libfibre
Commits
44518827
Commit
44518827
authored
2 years ago
by
Martin Karsten
Browse files
Options
Downloads
Patches
Plain Diff
- change fibre-specific destructors to run on fibre stack
parent
d981074a
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/libfibre/Cluster.cc
+4
-4
4 additions, 4 deletions
src/libfibre/Cluster.cc
src/libfibre/Fibre.h
+18
-10
18 additions, 10 deletions
src/libfibre/Fibre.h
src/runtime-glue/RuntimeFred.h
+5
-7
5 additions, 7 deletions
src/runtime-glue/RuntimeFred.h
src/runtime/Fred.h
+1
-1
1 addition, 1 deletion
src/runtime/Fred.h
with
28 additions
and
22 deletions
src/libfibre/Cluster.cc
+
4
−
4
View file @
44518827
...
...
@@ -133,8 +133,8 @@ Fibre* Cluster::registerWorker(_friend<EventScope>) {
Worker
*
worker
=
new
Worker
(
*
this
);
Fibre
*
mainFibre
=
new
Fibre
(
*
worker
,
Fibre
::
DefaultAffinity
,
_friend
<
Cluster
>
(),
0
);
// caller continues on pthread stack
setupWorker
(
mainFibre
,
worker
);
Fibre
*
idleFibre
=
new
Fibre
(
*
worker
,
Fibre
::
FixedAffinity
,
_friend
<
Cluster
>
());
// idle fibre on new stack
idleFibre
->
setup
((
ptr_t
)
fibreHelper
,
worker
);
// set up idle fibre for execution
Fibre
*
idleFibre
=
new
Fibre
(
*
worker
,
Fibre
::
FixedAffinity
,
_friend
<
Cluster
>
());
// idle fibre on new stack
idleFibre
->
setup
((
ptr_t
)
fibreHelper
,
worker
,
nullptr
,
idleFibre
,
_friend
<
Cluster
>
());
// set up idle fibre for execution
worker
->
setIdleLoop
(
idleFibre
);
return
mainFibre
;
}
...
...
@@ -143,9 +143,9 @@ Cluster::Worker& Cluster::addWorker(funcvoid1_t initFunc, ptr_t initArg) {
Worker
*
worker
=
new
Worker
(
*
this
);
Fibre
*
initFibre
=
new
Fibre
(
*
worker
,
Fibre
::
FixedAffinity
,
_friend
<
Cluster
>
());
if
(
initFunc
)
{
// run init routine in dedicated fibre, so it can block
initFibre
->
setup
((
ptr_t
)
initFunc
,
initArg
);
initFibre
->
setup
((
ptr_t
)
initFunc
,
initArg
,
nullptr
,
initFibre
,
_friend
<
Cluster
>
()
);
}
else
{
initFibre
->
setup
((
ptr_t
)
initDummy
,
nullptr
);
initFibre
->
setup
((
ptr_t
)
initDummy
,
nullptr
,
nullptr
,
initFibre
,
_friend
<
Cluster
>
()
);
}
Argpack
args
=
{
this
,
worker
,
initFibre
};
pthread_t
tid
;
...
...
This diff is collapsed.
Click to expand it.
src/libfibre/Fibre.h
+
18
−
10
View file @
44518827
...
...
@@ -169,8 +169,12 @@ private:
#endif
}
Fibre
*
runInternal
(
ptr_t
func
,
ptr_t
p1
,
ptr_t
p2
,
ptr_t
p3
)
{
void
start
(
ptr_t
func
,
ptr_t
p1
,
ptr_t
p2
,
ptr_t
p3
)
{
// hide base class start()
Fred
::
start
(
func
,
p1
,
p2
,
p3
);
}
Fibre
*
runInternal
(
ptr_t
func
,
ptr_t
p1
,
ptr_t
p2
,
Fibre
*
This
)
{
start
(
func
,
p1
,
p2
,
This
);
return
this
;
}
...
...
@@ -201,32 +205,36 @@ public:
/** Exit fibre (with join, if not detached). */
static
void
exit
(
ptr_t
p
=
nullptr
)
__noreturn
;
// callback after Fred's main routine has finished
void
finalize
(
ptr_t
e
)
{
result
=
e
;
clearSpecific
();
}
// callback from Fred via Runtime after final context switch
void
destroy
(
_friend
<
Fred
>
)
{
clearSpecific
();
clearDebug
();
stackFree
();
done
.
post
();
}
void
setup
(
ptr_t
func
,
ptr_t
p1
,
ptr_t
p2
,
ptr_t
p3
,
_friend
<
Cluster
>
)
{
// hide base class setup()
Fred
::
setup
(
func
,
p1
,
p2
,
p3
);
}
/** Start fibre. */
Fibre
*
run
(
void
(
*
func
)())
{
return
runInternal
((
ptr_t
)
func
,
nullptr
,
nullptr
,
nullptr
);
return
runInternal
((
ptr_t
)
func
,
nullptr
,
nullptr
,
this
);
}
/** Start fibre. */
template
<
typename
T1
>
Fibre
*
run
(
void
(
*
func
)(
T1
*
),
T1
*
p1
)
{
return
runInternal
((
ptr_t
)
func
,
(
ptr_t
)
p1
,
nullptr
,
nullptr
);
}
/** Start fibre. */
template
<
typename
T1
,
typename
T2
>
Fibre
*
run
(
void
(
*
func
)(
T1
*
,
T2
*
),
T1
*
p1
,
T2
*
p2
)
{
return
runInternal
((
ptr_t
)
func
,
(
ptr_t
)
p1
,
(
ptr_t
)
p2
,
nullptr
);
return
runInternal
((
ptr_t
)
func
,
(
ptr_t
)
p1
,
nullptr
,
this
);
}
/** Start fibre with pthread-type run function. */
template
<
typename
T1
>
Fibre
*
run
(
void
*
(
*
func
)(
T1
*
),
T1
*
p1
)
{
return
runInternal
((
ptr_t
)
func
,
(
ptr_t
)
p1
,
nullptr
,
&
result
);
return
runInternal
((
ptr_t
)
func
,
(
ptr_t
)
p1
,
nullptr
,
this
);
}
/** Sleep. */
...
...
This diff is collapsed.
Click to expand it.
src/runtime-glue/RuntimeFred.h
+
5
−
7
View file @
44518827
...
...
@@ -21,16 +21,14 @@
inline
void
RuntimeStartFred
(
funcvoid3_t
func
,
ptr_t
arg1
,
ptr_t
arg2
,
ptr_t
arg3
)
{
Context
::
CurrProcessor
().
countFredStarted
();
ptr_t
p
;
try
{
if
(
arg3
)
{
funcptr3_t
f3
=
(
funcptr3_t
)(
ptr_t
)(
func
);
*
(
ptr_t
*
)
arg3
=
f3
(
arg1
,
arg2
,
arg3
);
}
else
{
func
(
arg1
,
arg2
,
arg3
);
}
funcptr3_t
f3
=
(
funcptr3_t
)(
ptr_t
)(
func
);
p
=
(
Fibre
::
ExitException
*
)
f3
(
arg1
,
arg2
,
arg3
);
}
catch
(
Fibre
::
ExitException
*
e
)
{
if
(
arg3
)
*
(
ptr_t
*
)
arg3
=
e
;
p
=
e
;
}
reinterpret_cast
<
Fibre
*>
(
arg3
)
->
finalize
(
p
);
}
inline
void
RuntimePreFredSwitch
(
Fred
&
currFred
,
Fred
&
nextFred
,
_friend
<
Fred
>
fs
)
{
...
...
This diff is collapsed.
Click to expand it.
src/runtime/Fred.h
+
1
−
1
View file @
44518827
...
...
@@ -119,7 +119,7 @@ public:
stackDirect
(
stackPointer
,
func
,
nullptr
,
nullptr
,
nullptr
);
}
// set up
new
fred
and resume for concurrent execution
// set up fred
stack without immediate start
void
setup
(
ptr_t
func
,
ptr_t
p1
=
nullptr
,
ptr_t
p2
=
nullptr
,
ptr_t
p3
=
nullptr
)
{
stackPointer
=
stackInit
(
stackPointer
,
func
,
p1
,
p2
,
p3
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment