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
c4e9736e
Commit
c4e9736e
authored
Nov 26, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lazy_init spawn option
parent
1d12ff72
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
12 deletions
+31
-12
libcaf_core/caf/detail/proper_actor.hpp
libcaf_core/caf/detail/proper_actor.hpp
+2
-2
libcaf_core/caf/policy/cooperative_scheduling.hpp
libcaf_core/caf/policy/cooperative_scheduling.hpp
+8
-3
libcaf_core/caf/policy/no_scheduling.hpp
libcaf_core/caf/policy/no_scheduling.hpp
+1
-1
libcaf_core/caf/spawn.hpp
libcaf_core/caf/spawn.hpp
+1
-1
libcaf_core/caf/spawn_options.hpp
libcaf_core/caf/spawn_options.hpp
+16
-2
libcaf_io/caf/io/broker.hpp
libcaf_io/caf/io/broker.hpp
+1
-1
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+1
-1
libcaf_io/src/broker.cpp
libcaf_io/src/broker.cpp
+1
-1
No files found.
libcaf_core/caf/detail/proper_actor.hpp
View file @
c4e9736e
...
...
@@ -64,10 +64,10 @@ class proper_actor_base : public Policies::resume_policy::template
scheduling_policy
().
enqueue
(
dptr
(),
sender
,
mid
,
msg
,
eu
);
}
inline
void
launch
(
bool
hide
,
execution_unit
*
host
)
{
inline
void
launch
(
bool
hide
,
bool
lazy
,
execution_unit
*
host
)
{
CAF_LOG_TRACE
(
""
);
this
->
is_registered
(
!
hide
);
this
->
scheduling_policy
().
launch
(
this
,
host
);
this
->
scheduling_policy
().
launch
(
this
,
host
,
lazy
);
}
template
<
class
F
>
...
...
libcaf_core/caf/policy/cooperative_scheduling.hpp
View file @
c4e9736e
...
...
@@ -40,14 +40,19 @@ class cooperative_scheduling {
using
timeout_type
=
int
;
template
<
class
Actor
>
inline
void
launch
(
Actor
*
self
,
execution_unit
*
host
)
{
inline
void
launch
(
Actor
*
self
,
execution_unit
*
host
,
bool
lazy
)
{
// detached in scheduler::worker::run
self
->
attach_to_scheduler
();
if
(
host
)
if
(
lazy
)
{
self
->
mailbox
().
try_block
();
return
;
}
if
(
host
)
{
host
->
exec_later
(
self
);
else
}
else
{
detail
::
singletons
::
get_scheduling_coordinator
()
->
enqueue
(
self
);
}
}
template
<
class
Actor
>
void
enqueue
(
Actor
*
self
,
const
actor_addr
&
sender
,
message_id
mid
,
...
...
libcaf_core/caf/policy/no_scheduling.hpp
View file @
c4e9736e
...
...
@@ -65,7 +65,7 @@ class no_scheduling {
}
template
<
class
Actor
>
void
launch
(
Actor
*
self
,
execution_unit
*
)
{
void
launch
(
Actor
*
self
,
execution_unit
*
,
bool
)
{
CAF_REQUIRE
(
self
!=
nullptr
);
CAF_PUSH_AID
(
self
->
id
());
CAF_LOG_TRACE
(
CAF_ARG
(
self
));
...
...
libcaf_core/caf/spawn.hpp
View file @
c4e9736e
...
...
@@ -114,7 +114,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host,
CAF_LOGF_DEBUG
(
"spawned actor with ID "
<<
ptr
->
id
());
CAF_PUSH_AID
(
ptr
->
id
());
before_launch_fun
(
ptr
.
get
());
ptr
->
launch
(
has_hide_flag
(
Os
),
host
);
ptr
->
launch
(
has_hide_flag
(
Os
),
h
as_lazy_init_flag
(
Os
),
h
ost
);
return
ptr
;
}
...
...
libcaf_core/caf/spawn_options.hpp
View file @
c4e9736e
...
...
@@ -40,8 +40,8 @@ enum class spawn_options : int {
detach_flag
=
0x04
,
hide_flag
=
0x08
,
blocking_api_flag
=
0x10
,
priority_aware_flag
=
0x20
priority_aware_flag
=
0x20
,
lazy_init_flag
=
0x40
};
#endif
...
...
@@ -95,6 +95,12 @@ constexpr spawn_options blocking_api = spawn_options::blocking_api_flag;
*/
constexpr
spawn_options
priority_aware
=
spawn_options
::
priority_aware_flag
;
/**
* Causes the new actor to delay its
* initialization until a message arrives.
*/
constexpr
spawn_options
lazy_init
=
spawn_options
::
lazy_init_flag
;
/**
* Checks wheter `haystack` contains `needle`.
* @relates spawn_options
...
...
@@ -151,6 +157,14 @@ constexpr bool has_blocking_api_flag(spawn_options opts) {
return
has_spawn_option
(
opts
,
blocking_api
);
}
/**
* Checks wheter the {@link lazy_init} flag is set in `opts`.
* @relates spawn_options
*/
constexpr
bool
has_lazy_init_flag
(
spawn_options
opts
)
{
return
has_spawn_option
(
opts
,
lazy_init
);
}
/** @} */
/** @cond PRIVATE */
...
...
libcaf_io/caf/io/broker.hpp
View file @
c4e9736e
...
...
@@ -297,7 +297,7 @@ class broker : public extend<local_actor>::
class
functor_based
;
void
launch
(
bool
is_hidden
,
execution_unit
*
);
void
launch
(
bool
is_hidden
,
bool
,
execution_unit
*
);
// <backward_compatibility version="0.9">
...
...
libcaf_io/caf/io/middleman.hpp
View file @
c4e9736e
...
...
@@ -62,7 +62,7 @@ class middleman : public detail::abstract_singleton {
return
static_cast
<
Impl
*>
(
i
->
second
.
get
());
}
intrusive_ptr
<
Impl
>
result
{
new
Impl
};
result
->
launch
(
true
,
nullptr
);
result
->
launch
(
true
,
false
,
nullptr
);
m_named_brokers
.
insert
(
std
::
make_pair
(
name
,
result
));
return
result
;
}
...
...
libcaf_io/src/broker.cpp
View file @
c4e9736e
...
...
@@ -266,7 +266,7 @@ void broker::cleanup(uint32_t reason) {
deref
();
// release implicit reference count from middleman
}
void
broker
::
launch
(
bool
is_hidden
,
execution_unit
*
)
{
void
broker
::
launch
(
bool
is_hidden
,
bool
,
execution_unit
*
)
{
// add implicit reference count held by the middleman
ref
();
is_registered
(
!
is_hidden
);
...
...
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