提交 c3be66af 编写于 作者: Y youngwolf

Fix the stand alone usage of the timer.

Eliminate the async call indicator (aci) as with the stand alone Asio.
上级 3ac25bb5
......@@ -43,7 +43,7 @@ else
endif
cflag += ${ext_cflag} ${boost_include_dir} -I../../include/
lflag += ${ext_libs} ${boost_lib_dir}
lflag += ${boost_lib_dir} ${ext_libs}
target = ${dir}/${module}
objects = ${patsubst %.cpp,${dir}/%.o,${wildcard *.cpp}}
......
......@@ -884,36 +884,8 @@
#ifdef _MSC_VER
#define ASCS_SF "%Iu" //format used to print 'size_t'
#ifndef ASCS_MIN_ACI_REF
#if BOOST_VERSION < 105500
#define ASCS_MIN_ACI_REF 3
#elif BOOST_VERSION < 107000
#define ASCS_MIN_ACI_REF 2
#elif BOOST_VERSION < 107400
#define ASCS_MIN_ACI_REF 3
#else
#define ASCS_MIN_ACI_REF 2
#endif
#endif
static_assert(_MSC_VER >= 1800, "ascs needs Visual C++ 12.0 (2013) or higher.");
#elif defined(__GNUC__)
#ifndef ASCS_MIN_ACI_REF
#if BOOST_VERSION < 105500
#define ASCS_MIN_ACI_REF 3
#elif BOOST_VERSION < 107000
#define ASCS_MIN_ACI_REF 2
#elif BOOST_VERSION < 107400
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
#define ASCS_MIN_ACI_REF 2
#else
#define ASCS_MIN_ACI_REF 3
#endif
#else
#define ASCS_MIN_ACI_REF 2
#endif
#endif
#ifdef __clang__
static_assert(__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1), "ascs needs Clang 3.1 or higher.");
#else
......
......@@ -734,18 +734,12 @@ private:
post_in_dis_strand([this]() {do_dispatch_msg();});
break;
case TIMER_DELAY_CLOSE:
if (!is_last_async_call())
{
auto re = is_last_async_call();
if (0 == re)
{
stop_all_timer(id);
return true;
}
else if (1 != re)
unified_out::fatal_out("fatal error, please contact the author immediately with the version of your boost and compiler.");
stop_all_timer(id);
return true;
}
if (lowest_layer().is_open())
else if (lowest_layer().is_open())
{
asio::error_code ec;
lowest_layer().close(ec);
......
......@@ -202,8 +202,8 @@ protected:
}
void reset_io_context_refs() {if (0 == io_context_refs) add_io_context_refs(1);}
virtual void attach_io_context(asio::io_context& io_context_, unsigned refs) = 0;
virtual void detach_io_context(asio::io_context& io_context_, unsigned refs) = 0;
virtual void attach_io_context(asio::io_context& io_context_, unsigned refs) {}
virtual void detach_io_context(asio::io_context& io_context_, unsigned refs) {}
private:
typedef std::list<timer_info> container_type;
......
......@@ -22,8 +22,8 @@ namespace ascs
class tracked_executor
{
protected:
tracked_executor(asio::io_context& _io_context_) : io_context_(_io_context_), aci(std::make_shared<char>((char) ASCS_MIN_ACI_REF)) {}
virtual ~tracked_executor() {}
tracked_executor(asio::io_context& _io_context_) : io_context_(_io_context_), aci(std::make_shared<char>('\0')) {}
public:
typedef std::function<void(const asio::error_code&)> handler_with_error;
......@@ -69,16 +69,8 @@ public:
{auto ref_holder(aci); return [=](const asio::error_code& ec, size_t bytes_transferred) {(void) ref_holder; handler(ec, bytes_transferred);};}
#endif
long get_aci_ref() const {return aci.use_count();}
bool is_async_calling() const {return !aci.unique();}
int is_last_async_call() const //can only be called in callbacks, 0-not, -1-fault error, 1-yes
{
long cur_ref = aci.use_count();
if (cur_ref > *aci)
return 0;
return cur_ref < *aci ? -1 : 1;
}
bool is_last_async_call() const {return aci.use_count() <= 2;} //can only be called in callbacks
inline void set_async_calling(bool) {}
protected:
......@@ -94,9 +86,8 @@ protected:
tracked_executor(asio::io_context& io_context_) : executor(io_context_), aci(false) {}
public:
inline long get_aci_ref() const {return -1;} //na
inline bool is_async_calling() const {return aci;}
inline int is_last_async_call() const {return 1;} //1-yes
inline bool is_last_async_call() const {return true;}
inline void set_async_calling(bool value) {aci = value;}
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册