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
e7f9e560
Commit
e7f9e560
authored
Sep 17, 2014
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change thrown exception to gcc compatibility
parent
b64f0644
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
libcaf_core/caf/mutex.hpp
libcaf_core/caf/mutex.hpp
+12
-7
libcaf_core/caf/thread.hpp
libcaf_core/caf/thread.hpp
+5
-3
libcaf_core/src/condition_variable.cpp
libcaf_core/src/condition_variable.cpp
+9
-14
No files found.
libcaf_core/caf/mutex.hpp
View file @
e7f9e560
...
...
@@ -23,7 +23,8 @@
#ifdef __RIOTBUILD_FLAG
#include <utility>
#include <system_error>
//#include <system_error>
#include <stdexcept>
#include <cstdio>
...
...
@@ -160,10 +161,12 @@ class unique_lock {
template
<
class
Mutex
>
void
unique_lock
<
Mutex
>::
lock
()
{
if
(
m_mtx
==
nullptr
)
{
std
::
__throw_system_error
(
EPERM
,
"unique_lock::lock: references null mutex"
);
//std::__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
throw
std
::
runtime_error
(
"unique_lock::lock: references null mutex"
);
}
if
(
m_owns
)
{
std
::
__throw_system_error
(
EDEADLK
,
"unique_lock::lock: already locked"
);
//std::__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
throw
std
::
runtime_error
(
""
);
}
m_mtx
->
lock
();
m_owns
=
true
;
...
...
@@ -172,11 +175,12 @@ void unique_lock<Mutex>::lock() {
template
<
class
Mutex
>
bool
unique_lock
<
Mutex
>::
try_lock
()
{
if
(
m_mtx
==
nullptr
)
{
std
::
__throw_system_error
(
EPERM
,
"unique_lock::try_lock: references null mutex"
);
//
std::__throw_system_error(EPERM,
throw
std
::
runtime_error
(
"unique_lock::try_lock: references null mutex"
);
}
if
(
m_owns
)
{
std
::
__throw_system_error
(
EDEADLK
,
"unique_lock::try_lock: already locked"
);
//std::__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
throw
std
::
runtime_error
(
"unique_lock::try_lock lock: already locked"
);
}
m_owns
=
m_mtx
->
try_lock
();
return
m_owns
;
...
...
@@ -215,7 +219,8 @@ bool unique_lock<Mutex>::try_lock() {
template
<
class
Mutex
>
void
unique_lock
<
Mutex
>::
unlock
()
{
if
(
!
m_owns
)
{
std
::
__throw_system_error
(
EPERM
,
"unique_lock::unlock: not locked"
);
//std::__throw_system_error(EPERM, "unique_lock::unlock: not locked");
throw
std
::
runtime_error
(
"unique_lock::unlock: not locked"
);
}
m_mtx
->
unlock
();
m_owns
=
false
;
...
...
libcaf_core/caf/thread.hpp
View file @
e7f9e560
...
...
@@ -26,11 +26,13 @@
#include <tuple>
#include <chrono>
#include <memory>
#include <utility>
#include <exception>
#include <functional>
#include <type_traits>
#include <system_error>
//#include <system_error>
#include <stdexcept>
extern
"C"
{
#include "thread.h"
...
...
@@ -191,8 +193,8 @@ thread::thread(F&& f, Args&&... args) {
if
(
m_handle
>=
0
)
{
p
.
release
();
}
else
{
std
::
__throw_system_error
(
static_cast
<
int
>
(
m_handle
),
"Failed to create thread."
);
//
std::__throw_system_error(static_cast<int>(m_handle),
throw
std
::
runtime_error
(
"Failed to create thread."
);
}
}
...
...
libcaf_core/src/condition_variable.cpp
View file @
e7f9e560
#include <system_error>
//#include <system_error>
#include <stdexcept>
extern
"C"
{
#include "irq.h"
#include "vtimer.h"
#include "sched.h"
#include "vtimer.h"
#include "priority_queue.h"
}
#include "caf/condition_variable.hpp"
...
...
@@ -14,32 +16,25 @@ using namespace std::chrono;
namespace
caf
{
condition_variable
::~
condition_variable
()
{
m_queue
.
first
=
NULL
;
m_queue
.
first
=
NULL
;
}
void
condition_variable
::
notify_one
()
noexcept
{
printf
(
"notify_one start
\n
"
);
unsigned
old_state
=
disableIRQ
();
priority_queue_node_t
*
head
=
priority_queue_remove_head
(
&
m_queue
);
int
other_prio
=
-
1
;
if
(
head
!=
NULL
)
{
printf
(
"notify_one -> head is not NULL
\n
"
);
tcb_t
*
other_thread
=
(
tcb_t
*
)
sched_threads
[
head
->
data
];
if
(
other_thread
)
{
printf
(
"notify_one -> other thread exists
\n
"
);
other_prio
=
other_thread
->
priority
;
sched_set_status
(
other_thread
,
STATUS_PENDING
);
}
head
->
data
=
-
1u
;
}
restoreIRQ
(
old_state
);
printf
(
"notify_one -> restored irq
\n
"
);
if
(
other_prio
>=
0
)
{
printf
(
"notify_one -> sched_switch incoming
\n
"
);
sched_switch
(
other_prio
);
printf
(
"notify_one -> sched_switch called
\n
"
);
}
printf
(
"notify_one end
\n
"
);
}
void
condition_variable
::
notify_all
()
noexcept
{
...
...
@@ -68,8 +63,8 @@ void condition_variable::notify_all() noexcept {
void
condition_variable
::
wait
(
unique_lock
<
mutex
>&
lock
)
noexcept
{
if
(
!
lock
.
owns_lock
())
{
std
::
__throw_system_error
(
EPERM
,
"condition_variable::wait: mutex not locked"
);
//
std::__throw_system_error(EPERM,
throw
std
::
runtime_error
(
"condition_variable::wait: mutex not locked"
);
}
priority_queue_node_t
n
;
n
.
priority
=
sched_active_thread
->
priority
;
...
...
@@ -95,8 +90,8 @@ void condition_variable::wait(unique_lock<mutex>& lock) noexcept {
time_point
<
system_clock
,
nanoseconds
>
tp
)
noexcept
{
if
(
!
lock
.
owns_lock
())
{
std
::
__throw_system_error
(
EPERM
,
"condition_variable::timed wait: mutex not locked"
);
//
std::__throw_system_error(EPERM,
throw
std
::
runtime_error
(
"condition_variable::timed wait: mutex not locked"
);
}
nanoseconds
d
=
tp
.
time_since_epoch
();
if
(
d
>
nanoseconds
(
0x59682F000000E941
))
{
...
...
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