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
585a8091
Commit
585a8091
authored
Jan 07, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all actors use `memory::create` instead of `new`
parent
4cdba90f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
10 deletions
+15
-10
cppa/actor_companion_mixin.hpp
cppa/actor_companion_mixin.hpp
+1
-1
cppa/detail/event_based_actor_factory.hpp
cppa/detail/event_based_actor_factory.hpp
+3
-2
src/scheduler.cpp
src/scheduler.cpp
+6
-3
src/self.cpp
src/self.cpp
+1
-1
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+4
-3
No files found.
cppa/actor_companion_mixin.hpp
View file @
585a8091
...
@@ -58,7 +58,7 @@ class actor_companion_mixin : public Base {
...
@@ -58,7 +58,7 @@ class actor_companion_mixin : public Base {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
actor_companion_mixin
(
Args
&&
...
args
)
:
super
(
std
::
forward
<
Args
>
(
args
)...)
{
actor_companion_mixin
(
Args
&&
...
args
)
:
super
(
std
::
forward
<
Args
>
(
args
)...)
{
m_self
.
reset
(
new
companion
(
this
));
m_self
.
reset
(
detail
::
memory
::
create
<
companion
>
(
this
));
}
}
~
actor_companion_mixin
()
{
~
actor_companion_mixin
()
{
...
...
cppa/detail/event_based_actor_factory.hpp
View file @
585a8091
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "cppa/event_based_actor.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/memory.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
...
@@ -103,8 +104,8 @@ class event_based_actor_factory {
...
@@ -103,8 +104,8 @@ class event_based_actor_factory {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
actor_ptr
spawn
(
Args
&&
...
args
)
{
actor_ptr
spawn
(
Args
&&
...
args
)
{
return
get_scheduler
()
->
spawn
(
new
impl
(
m_init
,
m_on_exit
,
return
get_scheduler
()
->
spawn
(
memory
::
create
<
impl
>
(
m_init
,
m_on_exit
,
std
::
forward
<
Args
>
(
args
)...));
std
::
forward
<
Args
>
(
args
)...));
}
}
private:
private:
...
...
src/scheduler.cpp
View file @
585a8091
...
@@ -127,10 +127,12 @@ class scheduler_helper {
...
@@ -127,10 +127,12 @@ class scheduler_helper {
typedef
intrusive_ptr
<
thread_mapped_actor
>
ptr_type
;
typedef
intrusive_ptr
<
thread_mapped_actor
>
ptr_type
;
void
start
()
{
void
start
()
{
ptr_type
mtimer
{
new
thread_mapped_actor
};
ptr_type
mtimer
{
detail
::
memory
::
create
<
thread_mapped_actor
>
()};
ptr_type
mprinter
{
new
thread_mapped_actor
};
ptr_type
mprinter
{
detail
::
memory
::
create
<
thread_mapped_actor
>
()};
// launch threads
m_timer_thread
=
std
::
thread
(
&
scheduler_helper
::
timer_loop
,
mtimer
);
m_timer_thread
=
std
::
thread
(
&
scheduler_helper
::
timer_loop
,
mtimer
);
m_printer_thread
=
std
::
thread
(
&
scheduler_helper
::
printer_loop
,
mprinter
);
m_printer_thread
=
std
::
thread
(
&
scheduler_helper
::
printer_loop
,
mprinter
);
// set member variables
m_timer
=
mtimer
;
m_timer
=
mtimer
;
m_printer
=
mprinter
;
m_printer
=
mprinter
;
}
}
...
@@ -291,9 +293,10 @@ void scheduler_helper::printer_loop(ptr_type m_self) {
...
@@ -291,9 +293,10 @@ void scheduler_helper::printer_loop(ptr_type m_self) {
);
);
}
}
scheduler
::
scheduler
()
:
m_helper
(
n
ew
scheduler_helpe
r
)
{
}
scheduler
::
scheduler
()
:
m_helper
(
n
ullpt
r
)
{
}
void
scheduler
::
initialize
()
{
void
scheduler
::
initialize
()
{
m_helper
=
new
scheduler_helper
;
m_helper
->
start
();
m_helper
->
start
();
}
}
...
...
src/self.cpp
View file @
585a8091
...
@@ -44,7 +44,7 @@ pthread_key_t s_key;
...
@@ -44,7 +44,7 @@ pthread_key_t s_key;
pthread_once_t
s_key_once
=
PTHREAD_ONCE_INIT
;
pthread_once_t
s_key_once
=
PTHREAD_ONCE_INIT
;
local_actor
*
tss_constructor
()
{
local_actor
*
tss_constructor
()
{
local_actor
*
result
=
new
thread_mapped_actor
;
local_actor
*
result
=
detail
::
memory
::
create
<
thread_mapped_actor
>
()
;
result
->
ref
();
result
->
ref
();
get_scheduler
()
->
register_converted_context
(
result
);
get_scheduler
()
->
register_converted_context
(
result
);
return
result
;
return
result
;
...
...
src/thread_pool_scheduler.cpp
View file @
585a8091
...
@@ -205,7 +205,7 @@ actor_ptr thread_pool_scheduler::spawn_as_thread(void_function fun,
...
@@ -205,7 +205,7 @@ actor_ptr thread_pool_scheduler::spawn_as_thread(void_function fun,
init_callback
cb
,
init_callback
cb
,
bool
hidden
)
{
bool
hidden
)
{
if
(
!
hidden
)
inc_actor_count
();
if
(
!
hidden
)
inc_actor_count
();
thread_mapped_actor_ptr
ptr
{
new
thread_mapped_actor
(
std
::
move
(
fun
))};
thread_mapped_actor_ptr
ptr
{
detail
::
memory
::
create
<
thread_mapped_actor
>
(
std
::
move
(
fun
))};
ptr
->
init
();
ptr
->
init
();
ptr
->
initialized
(
true
);
ptr
->
initialized
(
true
);
cb
(
ptr
.
get
());
cb
(
ptr
.
get
());
...
@@ -257,7 +257,7 @@ actor_ptr thread_pool_scheduler::spawn(scheduled_actor* raw,
...
@@ -257,7 +257,7 @@ actor_ptr thread_pool_scheduler::spawn(scheduled_actor* raw,
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
scheduling_hint
hint
)
{
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
scheduling_hint
hint
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
scheduled_actor_ptr
ptr
{
new
context_switching_actor
(
std
::
move
(
fun
))};
scheduled_actor_ptr
ptr
{
detail
::
memory
::
create
<
context_switching_actor
>
(
std
::
move
(
fun
))};
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
return
spawn_impl
(
std
::
move
(
ptr
));
return
spawn_impl
(
std
::
move
(
ptr
));
}
}
...
@@ -267,11 +267,12 @@ actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint)
...
@@ -267,11 +267,12 @@ actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint)
hint
==
detached_and_hidden
);
hint
==
detached_and_hidden
);
}
}
}
}
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
init_callback
init_cb
,
init_callback
init_cb
,
scheduling_hint
hint
)
{
scheduling_hint
hint
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
scheduled_actor_ptr
ptr
{
new
context_switching_actor
(
std
::
move
(
fun
))};
scheduled_actor_ptr
ptr
{
detail
::
memory
::
create
<
context_switching_actor
>
(
std
::
move
(
fun
))};
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
init_cb
(
ptr
.
get
());
init_cb
(
ptr
.
get
());
return
spawn_impl
(
std
::
move
(
ptr
));
return
spawn_impl
(
std
::
move
(
ptr
));
...
...
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