Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
7f79cc2b
Commit
7f79cc2b
authored
May 22, 2015
by
Michael Arntzenius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make mutexes check their return codes
parent
2588a25f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
src/core/thread_utils.h
src/core/thread_utils.h
+20
-4
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+1
-0
No files found.
src/core/thread_utils.h
View file @
7f79cc2b
...
...
@@ -52,11 +52,20 @@ public:
class
PthreadFastMutex
{
private:
// NB. I tried using error-checking mutexes (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) here in debug-mode but got
// some funky errors. I think we might be deliberately locking/unlocking mutexes on different threads in some
// circumstances. - rntz
pthread_mutex_t
mutex
=
PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
;
public:
void
lock
()
{
pthread_mutex_lock
(
&
mutex
);
}
void
unlock
()
{
pthread_mutex_unlock
(
&
mutex
);
}
void
lock
()
{
int
err
=
pthread_mutex_lock
(
&
mutex
);
ASSERT
(
!
err
,
"pthread_mutex_lock failed, error code %d"
,
err
);
}
void
unlock
()
{
int
err
=
pthread_mutex_unlock
(
&
mutex
);
ASSERT
(
!
err
,
"pthread_mutex_unlock failed, error code %d"
,
err
);
}
PthreadFastMutex
*
asRead
()
{
return
this
;
}
PthreadFastMutex
*
asWrite
()
{
return
this
;
}
...
...
@@ -64,11 +73,18 @@ public:
class
PthreadMutex
{
private:
// Ditto comment in PthreadFastMutex re error-checking mutexes. - rntz
pthread_mutex_t
mutex
=
PTHREAD_MUTEX_INITIALIZER
;
public:
void
lock
()
{
pthread_mutex_lock
(
&
mutex
);
}
void
unlock
()
{
pthread_mutex_unlock
(
&
mutex
);
}
void
lock
()
{
int
err
=
pthread_mutex_lock
(
&
mutex
);
ASSERT
(
!
err
,
"pthread_mutex_lock failed, error code %d"
,
err
);
}
void
unlock
()
{
int
err
=
pthread_mutex_unlock
(
&
mutex
);
ASSERT
(
!
err
,
"pthread_mutex_unlock failed, error code %d"
,
err
);
}
PthreadMutex
*
asRead
()
{
return
this
;
}
PthreadMutex
*
asWrite
()
{
return
this
;
}
...
...
src/runtime/builtin_modules/thread.cpp
View file @
7f79cc2b
...
...
@@ -134,6 +134,7 @@ public:
success
=
(
status
==
0
)
?
1
:
0
;
RELEASE_ASSERT
(
status
==
0
||
!
waitflag
,
"could not lock mutex! error %d"
,
status
);
return
boxBool
(
status
==
0
);
}
...
...
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