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
ffd73d2a
Commit
ffd73d2a
authored
Sep 03, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Neverlord/libcppa
parents
cfcfedfb
0242637b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
3 deletions
+42
-3
cppa/scheduler.hpp
cppa/scheduler.hpp
+5
-0
src/scheduler.cpp
src/scheduler.cpp
+37
-3
No files found.
cppa/scheduler.hpp
View file @
ffd73d2a
...
@@ -11,6 +11,7 @@ namespace cppa {
...
@@ -11,6 +11,7 @@ namespace cppa {
class
context
;
class
context
;
class
actor_behavior
;
class
actor_behavior
;
class
scheduler_helper
;
/**
/**
* @brief
* @brief
...
@@ -18,8 +19,12 @@ class actor_behavior;
...
@@ -18,8 +19,12 @@ class actor_behavior;
class
scheduler
class
scheduler
{
{
scheduler_helper
*
m_helper
;
protected:
protected:
scheduler
();
/**
/**
* @brief Calls {@link context::exit(std::uint32_t) context::exit}.
* @brief Calls {@link context::exit(std::uint32_t) context::exit}.
*/
*/
...
...
src/scheduler.cpp
View file @
ffd73d2a
...
@@ -8,14 +8,15 @@
...
@@ -8,14 +8,15 @@
#include "cppa/context.hpp"
#include "cppa/context.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/detail/actor_count.hpp"
#include "cppa/detail/actor_count.hpp"
//
#include "cppa/detail/mock_scheduler.hpp"
#include "cppa/detail/mock_scheduler.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/converted_thread_context.hpp"
namespace
{
namespace
{
//std::mutex m_instance_mtx;
std
::
atomic
<
cppa
::
scheduler
*>
m_instance
;
std
::
atomic
<
cppa
::
scheduler
*>
m_instance
;
/*
struct static_cleanup_helper
struct static_cleanup_helper
{
{
~static_cleanup_helper()
~static_cleanup_helper()
...
@@ -32,13 +33,46 @@ struct static_cleanup_helper
...
@@ -32,13 +33,46 @@ struct static_cleanup_helper
}
}
}
}
s_cleanup_helper;
s_cleanup_helper;
*/
}
// namespace <anonymous>
}
// namespace <anonymous>
namespace
cppa
{
namespace
cppa
{
class
scheduler_helper
{
cppa
::
intrusive_ptr
<
cppa
::
context
>
m_worker
;
static
void
worker_loop
(
cppa
::
intrusive_ptr
<
cppa
::
context
>
m_self
);
public:
scheduler_helper
()
:
m_worker
(
new
detail
::
converted_thread_context
)
{
// do NOT increase actor count; worker is "invisible"
boost
::
thread
(
&
scheduler_helper
::
worker_loop
,
m_worker
).
detach
();
}
~
scheduler_helper
()
{
m_worker
->
enqueue
(
message
(
m_worker
,
m_worker
,
atom
(
":_DIE"
)));
}
};
void
scheduler_helper
::
worker_loop
(
cppa
::
intrusive_ptr
<
cppa
::
context
>
m_self
)
{
set_self
(
m_self
.
get
());
}
scheduler
::
scheduler
()
:
m_helper
(
new
scheduler_helper
)
{
}
scheduler
::~
scheduler
()
scheduler
::~
scheduler
()
{
{
delete
m_helper
;
}
}
void
scheduler
::
await_others_done
()
void
scheduler
::
await_others_done
()
...
@@ -71,7 +105,7 @@ void set_scheduler(scheduler* sched)
...
@@ -71,7 +105,7 @@ void set_scheduler(scheduler* sched)
scheduler
*
s
=
nullptr
;
scheduler
*
s
=
nullptr
;
if
(
m_instance
.
compare_exchange_weak
(
s
,
sched
)
==
false
)
if
(
m_instance
.
compare_exchange_weak
(
s
,
sched
)
==
false
)
{
{
throw
std
::
runtime_error
(
"
cannot set scheduler
"
);
throw
std
::
runtime_error
(
"
scheduler already set
"
);
}
}
}
}
...
...
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