Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
vite
Commits
d5e3f649
Commit
d5e3f649
authored
Jun 27, 2011
by
Augustin Degomme
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use QMutexLocker to handle threading issues with QMutexes and avoid assertion failures on windows
parent
6351b288
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
27 deletions
+29
-27
src/core/Core.cpp
src/core/Core.cpp
+8
-8
src/parser/BuilderThread.cpp
src/parser/BuilderThread.cpp
+5
-4
src/parser/ParsingThread.cpp
src/parser/ParsingThread.cpp
+6
-7
src/parser/mt_ParserPaje.cpp
src/parser/mt_ParserPaje.cpp
+3
-2
src/trace/SerializerDispatcher.cpp
src/trace/SerializerDispatcher.cpp
+3
-2
src/trace/SerializerWriter.cpp
src/trace/SerializerWriter.cpp
+2
-2
src/trace/TraceBuilderThread.cpp
src/trace/TraceBuilderThread.cpp
+2
-2
No files found.
src/core/Core.cpp
View file @
d5e3f649
...
...
@@ -333,9 +333,9 @@ bool Core::draw_trace(const string & filename, const int format) {
//#else
// sleep(1); // We wait 1 second
if
(
!
parser
->
is_end_of_parsing
()){
mutex
.
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
&
mutex
);
finished
.
wait
(
&
mutex
,
1000
);
mutex
.
unlock
();
}
loaded_f
=
parser
->
get_percent_loaded
();
loaded
=
(
int
)(
loaded_f
*
100.0
f
);
...
...
@@ -362,8 +362,9 @@ bool Core::draw_trace(const string & filename, const int format) {
_trace
->
updateTrace
(
i
);
}
}
else
{
#endif
mutex
.
lock
();
#endif
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
&
mutex
);
if
(
format
!=
_STATE_SPLITTING
)
{
emit
build_finished
();
...
...
@@ -385,11 +386,10 @@ bool Core::draw_trace(const string & filename, const int format) {
}
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
finished
.
wait
(
&
mutex
);
}
#endif
mutex
.
unlock
();
}
cout
<<
QObject
::
tr
(
"Loading of the trace : "
).
toStdString
()
<<
loaded
<<
"%"
;
...
...
@@ -422,10 +422,10 @@ bool Core::draw_trace(const string & filename, const int format) {
cout
<<
QObject
::
tr
(
"Canceled at "
).
toStdString
()
<<
loaded
<<
"%"
<<
endl
;
parser
->
set_canceled
();
*
Message
::
get_instance
()
<<
QObject
::
tr
(
"The trace opening was canceled by the user at "
).
toStdString
()
<<
loaded
<<
"%"
<<
Message
::
ende
;
mutex
.
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
&
mutex
);
emit
build_finished
();
finished
.
wait
(
&
mutex
);
mutex
.
unlock
();
break
;
// Quit the loop
}
}
...
...
src/parser/BuilderThread.cpp
View file @
d5e3f649
...
...
@@ -100,15 +100,16 @@ bool BuilderThread::is_finished(){return _is_finished;}
void
BuilderThread
::
finish_build
(){
//quit();
//finish the TraceBuilderThread before closing this one
_mutex2
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker2
(
_mutex2
);
emit
build_finished
();
_trace_cond
->
wait
(
_mutex2
);
_mutex2
->
unlock
();
locker2
.
unlock
();
_is_finished
=
true
;
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_cond
->
wakeAll
();
_mutex
->
unlock
();
}
src/parser/ParsingThread.cpp
View file @
d5e3f649
...
...
@@ -69,10 +69,9 @@ void ParsingThread::run() {
catch
(
const
std
::
string
&
)
{
_parser
->
finish
();
}
_mutex
->
lock
(
);
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_finished
->
wakeAll
();
_mutex
->
unlock
();
}
...
...
@@ -80,9 +79,9 @@ void ParsingThread::finish_build(){
_is_finished
=
true
;
_trace
->
finish
();
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_finished
->
wakeAll
();
_mutex
->
unlock
();
}
void
ParsingThread
::
dump
(
std
::
string
path
,
std
::
string
filename
){
...
...
@@ -90,8 +89,8 @@ void ParsingThread::dump(std::string path, std::string filename){
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
_trace
->
dump
(
path
,
filename
);
#endif
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_finished
->
wakeAll
();
_mutex
->
unlock
();
}
src/parser/mt_ParserPaje.cpp
View file @
d5e3f649
...
...
@@ -241,10 +241,11 @@ void mt_ParserPaje::parse(Trace &trace,
line
=
NULL
;
//send the finish signal to the BuilderThread, which will do the same to the TraceBuilderThread
//both threads will then be finished and ready to destroy
mutex
.
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
&
mutex
);
emit
build_finish
();
ended
.
wait
(
&
mutex
);
mutex
.
unlock
();
locker
.
unlock
();
traceBuilderThread
.
quit
();
traceBuilderThread
.
wait
();
consumerThread
.
quit
();
...
...
src/trace/SerializerDispatcher.cpp
View file @
d5e3f649
...
...
@@ -70,11 +70,12 @@ void SerializerDispatcher::kill_all_threads(){
_evt_array
[
i
].
connect
((
const
QObject
*
)
this
,
SIGNAL
(
build_finish
()),
SLOT
(
finish_build
()));
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
emit
build_finish
();
QWaitCondition
*
_cond
=
_evt_array
[
i
].
get_cond
();
_cond
->
wait
(
_mutex
);
_mutex
->
unlock
();
locker
.
unlock
();
_evt_array
[
i
].
get_thread
()
->
quit
();
}
...
...
src/trace/SerializerWriter.cpp
View file @
d5e3f649
...
...
@@ -76,10 +76,10 @@ void SerializerWriter::dump_on_disk(IntervalOfContainer* itc,const char* filenam
bool
SerializerWriter
::
is_finished
(){
return
_is_finished
;}
void
SerializerWriter
::
finish_build
(){
// printf("répondons : %p _this %p %p\n", _thread,this, _cond);
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_is_finished
=
true
;
_cond
->
wakeAll
();
_mutex
->
unlock
();
}
src/trace/TraceBuilderThread.cpp
View file @
d5e3f649
...
...
@@ -44,10 +44,10 @@ TraceBuilderThread::TraceBuilderThread(QWaitCondition* cond, QSemaphore * freeS
}
void
TraceBuilderThread
::
build_finished
(){
_mutex
->
lock
();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker
locker
(
_mutex
);
_is_finished
=
true
;
_cond
->
wakeAll
();
_mutex
->
unlock
();
}
void
TraceBuilderThread
::
define_container_type
(
Trace_builder_struct
*
tb_struct
){
...
...
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