Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
7016c8a8
A
ascs
项目概览
youngwolf
/
ascs
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ascs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7016c8a8
编写于
10月 05, 2018
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Not support concurrent queue any more.
上级
fb43af90
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
79 deletion
+22
-79
examples/config.mk
examples/config.mk
+2
-7
include/ascs/config.h
include/ascs/config.h
+20
-37
include/ascs/container.h
include/ascs/container.h
+0
-35
未找到文件。
examples/config.mk
浏览文件 @
7016c8a8
# If your compiler cannot find asio, please specify it explicitly like this:
#
ext_location
= -I/path of asio/
#
asio_dir
= -I/path of asio/
# asio.hpp and asio directory should be available in this place.
# If possible, -std=c++14 or -std=c++1y would be better.
...
...
@@ -15,11 +15,6 @@ else
endif
cflag
+=
-DASIO_STANDALONE
-DASIO_NO_DEPRECATED
# If you used concurrent queue (https://github.com/cameron314/concurrentqueue), please define ASCS_HAS_CONCURRENT_QUEUE macro:
#cflag += -DASCS_HAS_CONCURRENT_QUEUE
# And guarantee header file concurrentqueue.h is reachable, for example, add its path to ext_location:
#ext_location += -I/path of concurrent queue/
kernel
=
${
shell
uname
-s
}
ifeq
(${kernel}, SunOS)
cflag
+=
-pthreads
...
...
@@ -35,7 +30,7 @@ else
endif
endif
cflag
+=
${ext_cflag}
${
ext_location
}
-I
../../include/
cflag
+=
${ext_cflag}
${
asio_dir
}
-I
../../include/
lflag
+=
${ext_libs}
target
=
${dir}
/
${module}
...
...
include/ascs/config.h
浏览文件 @
7016c8a8
...
...
@@ -9,10 +9,10 @@
*
* ascs top header file.
*
* license: http://think-async.com/ (
the
current is www.boost.org/LICENSE_1_0.txt)
* license: http://think-async.com/ (current is www.boost.org/LICENSE_1_0.txt)
*
* Known issues:
* 1. since 1.1.0, concurrentqueue is not a FIFO queue (it is by design), navigate to the following links for more deatils:
* 1. since 1.1.0
until 1.3
, concurrentqueue is not a FIFO queue (it is by design), navigate to the following links for more deatils:
* https://github.com/cameron314/concurrentqueue/issues/6
* https://github.com/cameron314/concurrentqueue/issues/52
* if you're using concurrentqueue, please play attention, this is by design.
...
...
@@ -232,7 +232,7 @@
*
* SPECIAL ATTENTION (incompatible with old editions):
* Function object_pool::invalid_object_pop only pop obsoleted objects with no additional reference.
* socket::stat.last_recv_time will not be updated before tcp::socket_base::on_connect anymore.
* socket::stat.last_recv_time will not be updated before tcp::socket_base::on_connect any
more.
* For ssl socket, on_handshake will be invoked before on_connect (before, on_connect is before on_handshake).
*
* HIGHLIGHT:
...
...
@@ -309,10 +309,11 @@
* 2018.5.20 version 1.3.0
*
* SPECIAL ATTENTION (incompatible with old editions):
* Not support sync sending mode anymore.
* Not support concurrent queue any more.
* Not support sync sending mode any more.
* Explicitly need macro ASCS_PASSIVE_RECV to gain the ability of changing the unpacker at runtime.
* Function disconnect, force_shutdown and graceful_shutdown in udp::socket_base will now be performed asynchronously.
* Not support macro ASCS_FORCE_TO_USE_MSG_RECV_BUFFER anymore, which means now we have the behavior as this macro always defined,
* Not support macro ASCS_FORCE_TO_USE_MSG_RECV_BUFFER any
more, which means now we have the behavior as this macro always defined,
* thus, virtual function ascs::socket::on_msg() is useless and also has been deleted.
* statistic.handle_time_2_sum has been renamed to handle_time_sum.
* Macro ASCS_MSG_HANDLING_INTERVAL_STEP1 has been renamed to ASCS_MSG_RESUMING_INTERVAL.
...
...
@@ -331,7 +332,7 @@
* Introduced macro ASCS_DISPATCH_BATCH_MSG, then all messages will be dispatched via on_handle_msg with a variable-length contianer.
*
* FIX:
* Wiped race condition between async_read and async_write on the same ascs::socket, so sync sending mode will not be supported anymore.
* Wiped race condition between async_read and async_write on the same ascs::socket, so sync sending mode will not be supported any
more.
*
* ENHANCEMENTS:
* Explicitly define macro ASCS_PASSIVE_RECV to gain the ability of changing the unpacker at runtime.
...
...
@@ -345,7 +346,7 @@
* DELETION:
* Deleted macro ASCS_SEND_BUFFER_TYPE.
* Deleted virtual function bool ascs::socket::on_msg().
* Not support sync sending mode anymore, so we reduced an atomic object in ascs::socket.
* Not support sync sending mode any
more, so we reduced an atomic object in ascs::socket.
*
* REFACTORING:
* If you want to change unpacker at runtime, first, you must define macro ASCS_PASSIVE_RECV, second, you must call ascs::socket::recv_msg,
...
...
@@ -430,6 +431,7 @@
* macro ASCS_SYNC_DISPATCH been defined) and / or on_msg_handle.
*
* DELETION:
* Not support concurrent queue any more, so delete macro ASCS_HAS_CONCURRENT_QUEUE and class lock_free_queue.
*
* REFACTORING:
* Hide member variables as many as possible for developers.
...
...
@@ -619,36 +621,17 @@ static_assert(ASCS_ASYNC_ACCEPT_NUM > 0, "async accept number must be bigger tha
//close port reuse
//#define ASCS_NOT_REUSE_ADDRESS
//ConcurrentQueue is lock-free, please refer to https://github.com/cameron314/concurrentqueue
#ifdef ASCS_HAS_CONCURRENT_QUEUE
#include <concurrentqueue.h>
template
<
typename
T
>
using
concurrent_queue
=
moodycamel
::
ConcurrentQueue
<
T
>
;
#ifndef ASCS_INPUT_QUEUE
#define ASCS_INPUT_QUEUE lock_free_queue
#endif
#ifndef ASCS_INPUT_CONTAINER
#define ASCS_INPUT_CONTAINER concurrent_queue
#endif
#ifndef ASCS_OUTPUT_QUEUE
#define ASCS_OUTPUT_QUEUE lock_free_queue
#endif
#ifndef ASCS_OUTPUT_CONTAINER
#define ASCS_OUTPUT_CONTAINER concurrent_queue
#endif
#else
#ifndef ASCS_INPUT_QUEUE
#define ASCS_INPUT_QUEUE lock_queue
#endif
#ifndef ASCS_INPUT_CONTAINER
#define ASCS_INPUT_CONTAINER list
#endif
#ifndef ASCS_OUTPUT_QUEUE
#define ASCS_OUTPUT_QUEUE lock_queue
#endif
#ifndef ASCS_OUTPUT_CONTAINER
#define ASCS_OUTPUT_CONTAINER list
#endif
#ifndef ASCS_INPUT_QUEUE
#define ASCS_INPUT_QUEUE lock_queue
#endif
#ifndef ASCS_INPUT_CONTAINER
#define ASCS_INPUT_CONTAINER list
#endif
#ifndef ASCS_OUTPUT_QUEUE
#define ASCS_OUTPUT_QUEUE lock_queue
#endif
#ifndef ASCS_OUTPUT_CONTAINER
#define ASCS_OUTPUT_CONTAINER list
#endif
//we also can control the queues (and their containers) via template parameters on calss 'client_socket_base'
//'server_socket_base', 'ssl::client_socket_base' and 'ssl::server_socket_base'.
...
...
include/ascs/container.h
浏览文件 @
7016c8a8
...
...
@@ -157,41 +157,6 @@ private:
std
::
mutex
mutex
;
//std::mutex is more efficient than std::shared_(timed_)mutex
};
//Container must at least has the following functions (like concurrent_queue):
// Container() and Container(size_t) constructor
// move constructor
// size_approx (must be thread safe, but doesn't have to be coherent)
// swap
// enqueue(const T& item)
// enqueue(T&& item)
// try_dequeue(T& item)
template
<
typename
T
,
typename
Container
>
//thread safety depends on Container
#ifdef ASCS_DISPATCH_BATCH_MSG
class
lock_free_queue
:
public
Container
,
public
dummy_lockable
#else
class
lock_free_queue
:
protected
Container
,
public
dummy_lockable
#endif
{
public:
typedef
T
data_type
;
lock_free_queue
()
{}
lock_free_queue
(
size_t
capacity
)
:
Container
(
capacity
)
{}
bool
is_thread_safe
()
const
{
return
true
;}
size_t
size
()
const
{
return
this
->
size_approx
();}
bool
empty
()
const
{
return
0
==
size
();}
void
clear
()
{
Container
(
std
::
move
(
*
this
));}
using
Container
::
swap
;
void
move_items_in
(
std
::
list
<
T
>&
can
)
{
move_items_in_
(
can
);}
bool
enqueue_
(
const
T
&
item
)
{
return
this
->
enqueue
(
item
);}
bool
enqueue_
(
T
&&
item
)
{
return
this
->
enqueue
(
std
::
move
(
item
));}
void
move_items_in_
(
std
::
list
<
T
>&
can
)
{
do_something_to_all
(
can
,
[
this
](
T
&
item
)
{
this
->
enqueue
(
std
::
move
(
item
));});
can
.
clear
();}
bool
try_dequeue_
(
T
&
item
)
{
return
this
->
try_dequeue
(
item
);}
};
//Container must at least has the following functions (like list):
// Container() and Container(size_t) constructor
// size (must be thread safe, but doesn't have to be coherent, std::list before gcc 5 doesn't meet this requirement, ascs::list does)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录