Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
ff8bace6
Commit
ff8bace6
authored
Aug 29, 2004
by
Cyril Deguet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* async_queue.*: AsyncQueue::remove is now thread-safe to avoid potential
(but *very* unlikely) segfaults
parent
f53b5e07
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
modules/gui/skins2/commands/async_queue.cpp
modules/gui/skins2/commands/async_queue.cpp
+16
-4
modules/gui/skins2/commands/async_queue.hpp
modules/gui/skins2/commands/async_queue.hpp
+3
-1
No files found.
modules/gui/skins2/commands/async_queue.cpp
View file @
ff8bace6
...
...
@@ -29,6 +29,9 @@
AsyncQueue
::
AsyncQueue
(
intf_thread_t
*
pIntf
)
:
SkinObject
(
pIntf
)
{
// Initialize the mutex
vlc_mutex_init
(
pIntf
,
&
m_lock
);
// Create a timer
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pIntf
);
m_pTimer
=
pOsFactory
->
createOSTimer
(
Callback
(
this
,
&
doFlush
)
);
...
...
@@ -41,6 +44,7 @@ AsyncQueue::AsyncQueue( intf_thread_t *pIntf ): SkinObject( pIntf )
AsyncQueue
::~
AsyncQueue
()
{
delete
(
m_pTimer
);
vlc_mutex_destroy
(
&
m_lock
);
}
...
...
@@ -78,6 +82,8 @@ void AsyncQueue::push( const CmdGenericPtr &rcCommand )
void
AsyncQueue
::
remove
(
const
string
&
rType
)
{
vlc_mutex_lock
(
&
m_lock
);
list
<
CmdGenericPtr
>::
iterator
it
;
for
(
it
=
m_cmdList
.
begin
();
it
!=
m_cmdList
.
end
();
it
++
)
{
...
...
@@ -90,19 +96,25 @@ void AsyncQueue::remove( const string &rType )
it
=
itNew
;
}
}
vlc_mutex_unlock
(
&
m_lock
);
}
void
AsyncQueue
::
flush
()
{
vlc_mutex_lock
(
&
m_lock
);
while
(
m_cmdList
.
size
()
>
0
)
{
// Execute the first command in the queue
CmdGenericPtr
&
rcCommand
=
m_cmdList
.
front
();
rcCommand
.
get
()
->
execute
();
// And remove it
// Pop the first command from the queue
CmdGenericPtr
cCommand
=
m_cmdList
.
front
();
m_cmdList
.
pop_front
();
// And execute it
cCommand
.
get
()
->
execute
();
}
vlc_mutex_unlock
(
&
m_lock
);
}
...
...
modules/gui/skins2/commands/async_queue.hpp
View file @
ff8bace6
...
...
@@ -2,7 +2,7 @@
* async_queue.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id
: async_queue.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp
$
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
...
...
@@ -58,6 +58,8 @@ class AsyncQueue: public SkinObject
list
<
CmdGenericPtr
>
m_cmdList
;
/// Timer
OSTimer
*
m_pTimer
;
/// Mutex
vlc_mutex_t
m_lock
;
// Private because it is a singleton
AsyncQueue
(
intf_thread_t
*
pIntf
);
...
...
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