Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
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
videolan
vlc-2-2
Commits
ddf9e6da
Commit
ddf9e6da
authored
Aug 22, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: eventratelimiter: use mutex
parent
11104bf4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
modules/gui/qt4/util/uniqueevent.cpp
modules/gui/qt4/util/uniqueevent.cpp
+15
-2
modules/gui/qt4/util/uniqueevent.hpp
modules/gui/qt4/util/uniqueevent.hpp
+2
-0
No files found.
modules/gui/qt4/util/uniqueevent.cpp
View file @
ddf9e6da
...
...
@@ -21,10 +21,12 @@
#include <QTimer>
#include <QApplication>
#include <QMutex>
RateLimitedEventPoster
::
RateLimitedEventPoster
(
int
i_millisec_interval
)
{
timer
=
new
QTimer
();
mutex
=
new
QMutex
();
timer
->
setSingleShot
(
true
);
/* Assuming a 24fps event loop, delays at least events to the next frame */
if
(
i_millisec_interval
<
1
)
...
...
@@ -38,28 +40,39 @@ RateLimitedEventPoster::~RateLimitedEventPoster()
timer
->
stop
();
commit
();
delete
timer
;
delete
mutex
;
}
void
RateLimitedEventPoster
::
postEvent
(
UniqueEvent
*
e
,
QObject
*
target
)
{
event_tuple
newtuple
=
{
target
,
e
};
foreach
(
event_tuple
tuple
,
eventsList
)
mutex
->
lock
();
foreach
(
const
event_tuple
&
tuple
,
eventsList
)
{
if
(
target
==
tuple
.
target
&&
tuple
.
event
->
equals
(
e
)
)
{
delete
e
;
mutex
->
unlock
();
return
;
}
}
eventsList
<<
newtuple
;
mutex
->
unlock
();
if
(
eventsList
.
count
()
>=
100
)
/* limit lookup time */
{
timer
->
stop
();
commit
();
}
if
(
!
timer
->
isActive
()
)
timer
->
start
();
}
void
RateLimitedEventPoster
::
commit
()
{
foreach
(
event_tuple
tuple
,
eventsList
)
mutex
->
lock
();
foreach
(
const
event_tuple
&
tuple
,
eventsList
)
{
QApplication
::
postEvent
(
tuple
.
target
,
tuple
.
event
);
}
eventsList
.
clear
();
mutex
->
unlock
();
}
modules/gui/qt4/util/uniqueevent.hpp
View file @
ddf9e6da
...
...
@@ -22,6 +22,7 @@
#include <QEvent>
#include <QList>
class
QTimer
;
class
QMutex
;
class
UniqueEvent
:
public
QEvent
{
...
...
@@ -50,6 +51,7 @@ private:
};
QList
<
event_tuple
>
eventsList
;
QTimer
*
timer
;
QMutex
*
mutex
;
};
#endif // UNIQUEEVENT_HPP
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