Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
0aade9ad
There was an error fetching the commit references. Please try again later.
Commit
0aade9ad
authored
9 years ago
by
Emmanuel Gil Peyrot
Browse files
Options
Downloads
Patches
Plain Diff
Common: Remove unused fifo_queue.h.
parent
6a0eea93
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/CMakeLists.txt
+0
-1
0 additions, 1 deletion
src/common/CMakeLists.txt
src/common/fifo_queue.h
+0
-111
0 additions, 111 deletions
src/common/fifo_queue.h
with
0 additions
and
112 deletions
src/common/CMakeLists.txt
+
0
−
1
View file @
0aade9ad
...
...
@@ -31,7 +31,6 @@ set(HEADERS
cpu_detect.h
debug_interface.h
emu_window.h
fifo_queue.h
file_util.h
key_map.h
linear_disk_cache.h
...
...
This diff is collapsed.
Click to expand it.
src/common/fifo_queue.h
deleted
100644 → 0
+
0
−
111
View file @
6a0eea93
#pragma once
// a simple lockless thread-safe,
// single reader, single writer queue
#include
"common/atomic.h"
namespace
Common
{
template
<
typename
T
>
class
FifoQueue
{
public:
FifoQueue
()
:
m_size
(
0
)
{
m_write_ptr
=
m_read_ptr
=
new
ElementPtr
();
}
~
FifoQueue
()
{
// this will empty out the whole queue
delete
m_read_ptr
;
}
u32
Size
()
const
{
return
m_size
;
}
bool
Empty
()
const
{
//return (m_read_ptr == m_write_ptr)
;
return
(
0
==
m_size
);
}
T
&
Front
()
const
{
return
*
m_read_ptr
->
current
;
}
template
<
typename
Arg
>
void
Push
(
Arg
&&
t
)
{
// create the element, add it to the queue
m_write_ptr
->
current
=
new
T
(
std
::
forward
<
Arg
>
(
t
));
// set the next pointer to a new element ptr
// then advance the write pointer
m_write_ptr
=
m_write_ptr
->
next
=
new
ElementPtr
();
Common
::
AtomicIncrement
(
m_size
);
}
void
Pop
()
{
Common
::
AtomicDecrement
(
m_size
);
ElementPtr
*
const
tmpptr
=
m_read_ptr
;
// advance the read pointer
m_read_ptr
=
m_read_ptr
->
next
;
// set the next element to NULL to stop the recursive deletion
tmpptr
->
next
=
nullptr
;
delete
tmpptr
;
// this also deletes the element
}
bool
Pop
(
T
&
t
)
{
if
(
Empty
())
return
false
;
t
=
std
::
move
(
Front
());
Pop
();
return
true
;
}
// not thread-safe
void
Clear
()
{
m_size
=
0
;
delete
m_read_ptr
;
m_write_ptr
=
m_read_ptr
=
new
ElementPtr
();
}
private
:
// stores a pointer to element
// and a pointer to the next ElementPtr
class
ElementPtr
{
public:
ElementPtr
()
:
current
(
nullptr
),
next
(
nullptr
)
{}
~
ElementPtr
()
{
if
(
current
)
{
delete
current
;
// recusion ftw
if
(
next
)
delete
next
;
}
}
T
*
volatile
current
;
ElementPtr
*
volatile
next
;
};
ElementPtr
*
volatile
m_write_ptr
;
ElementPtr
*
volatile
m_read_ptr
;
volatile
u32
m_size
;
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment