Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
b0b02620
Commit
b0b02620
authored
Aug 18, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch svn r35084 & remove namespace baidu
Change-Id: Iaae684ff476283a237925fde0477cd75fe36be0d
parent
6d90ab2d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
29 deletions
+32
-29
bounded_queue.h
base/containers/bounded_queue.h
+31
-7
flat_map.h
base/containers/flat_map.h
+1
-1
id.cpp
bthread/id.cpp
+0
-11
task_group.cpp
bthread/task_group.cpp
+0
-10
No files found.
base/containers/bounded_queue.h
View file @
b0b02620
...
...
@@ -16,28 +16,52 @@
namespace
base
{
// NOTE: This version requires storage in ctor rather than allocating it,
// which is different from DP version.
// Example:
// [Create a on-stack small queue]
// char storage[64];
// base::BoundedQueue<int> q(storage, sizeof(storage), base::NOT_OWN_STORAGE);
// q.push(1);
// q.push(2);
// ...
// [Initialize a class-member queue]
// class Foo {
// ...
// BoundQueue<int> _queue;
// };
// int Foo::init() {
// BoundedQueue<int> tmp(capacity);
// if (!tmp.initialized()) {
// LOG(ERROR) << "Fail to create _queue";
// return -1;
// }
// tmp.swap(_queue);
// }
enum
StorageOwnership
{
OWNS_STORAGE
,
NOT_OWN_STORAGE
};
template
<
typename
T
>
class
BoundedQueue
{
public
:
// You have to pass the memory for storing items at creation.
// The queue contains at most
size /
sizeof(T) items.
BoundedQueue
(
void
*
spaces
,
size_t
size
,
StorageOwnership
ownership
)
// The queue contains at most
memsize/
sizeof(T) items.
BoundedQueue
(
void
*
mem
,
size_t
mem
size
,
StorageOwnership
ownership
)
:
_count
(
0
)
,
_cap
(
size
/
sizeof
(
T
))
,
_cap
(
mem
size
/
sizeof
(
T
))
,
_start
(
0
)
,
_ownership
(
ownership
)
,
_items
(
spaces
)
{
,
_items
(
mem
)
{
DCHECK
(
_items
);
};
// Construct a queue with the given capacity.
// The malloc() may fail sliently, call initialized() to test validity
// of the queue.
explicit
BoundedQueue
(
size_t
capacity
)
:
_count
(
0
)
,
_cap
(
capacity
)
,
_start
(
0
)
,
_ownership
(
OWNS_STORAGE
)
,
_items
(
malloc
(
capacity
*
sizeof
(
T
)))
{
DCHECK
(
_items
);
};
...
...
base/containers/flat_map.h
View file @
b0b02620
...
...
@@ -464,7 +464,7 @@ _T* find_lowered_cstr(FlatMap<std::string, _T, _Hash, _Equal, _Sparse>& m,
return
m
.
seek
(
*
tls_stringmap_temp
.
get_lowered_string
(
key
,
length
));
}
}
// namespace ba
idu
}
// namespace ba
se
#include "base/containers/flat_map_inl.h"
...
...
bthread/id.cpp
View file @
b0b02620
...
...
@@ -367,17 +367,6 @@ static int id_create_ranged_impl(
}
// namespace bthread
namespace
baidu
{
namespace
bthread
{
void
id_status
(
bthread_id_t
id
,
std
::
ostream
&
os
)
{
::
bthread
::
id_status
(
id
,
os
);
}
void
id_pool_status
(
std
::
ostream
&
os
)
{
::
bthread
::
id_pool_status
(
os
);
}
}
}
extern
"C"
{
int
bthread_id_create
(
...
...
bthread/task_group.cpp
View file @
b0b02620
...
...
@@ -917,13 +917,3 @@ void print_task(std::ostream& os, bthread_t tid) {
}
}
// namespace bthread
namespace
baidu
{
namespace
bthread
{
void
print_task
(
std
::
ostream
&
os
,
bthread_t
tid
)
{
::
bthread
::
print_task
(
os
,
tid
);
}
extern
BAIDU_THREAD_LOCAL
void
*
tls_unique_user_ptr
__attribute__
((
alias
(
"_ZN7bthread19tls_unique_user_ptrE"
)));
}
}
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