mirror of https://github.com/axmolengine/axmol.git
Sync yasio [ci build]
This commit is contained in:
parent
15da26ea92
commit
c6c3eedb99
|
@ -181,6 +181,7 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
|
|||
case YOPT_C_ENABLE_MCAST:
|
||||
case YOPT_C_LOCAL_ENDPOINT:
|
||||
case YOPT_C_REMOTE_ENDPOINT:
|
||||
case YOPT_C_MOD_FLAGS:
|
||||
service->set_option(opt, static_cast<int>(va[0]), va[1].as<const char*>(),
|
||||
static_cast<int>(va[2]));
|
||||
break;
|
||||
|
@ -324,6 +325,10 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
|
|||
YASIO_EXPORT_ENUM(YOPT_C_ENABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_DISABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_KCP_CONV);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_MOD_FLAGS);
|
||||
|
||||
YASIO_EXPORT_ENUM(YCF_REUSEADDR);
|
||||
YASIO_EXPORT_ENUM(YCF_EXCLUSIVEADDRUSE);
|
||||
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECT_RESPONSE);
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECTION_LOST);
|
||||
|
@ -533,6 +538,7 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
|
|||
case YOPT_C_ENABLE_MCAST:
|
||||
case YOPT_C_LOCAL_ENDPOINT:
|
||||
case YOPT_C_REMOTE_ENDPOINT:
|
||||
case YOPT_C_MOD_FLAGS:
|
||||
service->set_option(opt, static_cast<int>(args[0]),
|
||||
static_cast<const char*>(args[1]),
|
||||
static_cast<int>(args[2]));
|
||||
|
@ -679,6 +685,10 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
|
|||
YASIO_EXPORT_ENUM(YOPT_C_ENABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_DISABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_KCP_CONV);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_MOD_FLAGS);
|
||||
|
||||
YASIO_EXPORT_ENUM(YCF_REUSEADDR);
|
||||
YASIO_EXPORT_ENUM(YCF_EXCLUSIVEADDRUSE);
|
||||
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECT_RESPONSE);
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECTION_LOST);
|
||||
|
|
|
@ -1799,6 +1799,7 @@ bool js_yasio_io_service_set_option(JSContext* ctx, uint32_t argc, jsval* vp)
|
|||
case YOPT_C_ENABLE_MCAST:
|
||||
case YOPT_C_LOCAL_ENDPOINT:
|
||||
case YOPT_C_REMOTE_ENDPOINT:
|
||||
case YOPT_C_MOD_FLAGS:
|
||||
if (args[2].isString())
|
||||
{
|
||||
JSStringWrapper str(args[2].toString());
|
||||
|
@ -2038,6 +2039,10 @@ void jsb_register_yasio(JSContext* ctx, JS::HandleObject global)
|
|||
YASIO_EXPORT_ENUM(YOPT_C_ENABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_DISABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_KCP_CONV);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_MOD_FLAGS);
|
||||
|
||||
YASIO_EXPORT_ENUM(YCF_REUSEADDR);
|
||||
YASIO_EXPORT_ENUM(YCF_EXCLUSIVEADDRUSE);
|
||||
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECT_RESPONSE);
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECTION_LOST);
|
||||
|
|
|
@ -1385,6 +1385,7 @@ bool js_yasio_io_service_set_option(se::State& s)
|
|||
case YOPT_C_ENABLE_MCAST:
|
||||
case YOPT_C_LOCAL_ENDPOINT:
|
||||
case YOPT_C_REMOTE_ENDPOINT:
|
||||
case YOPT_C_MOD_FLAGS:
|
||||
service->set_option(opt, args[1].toInt32(), args[2].toString().c_str(),
|
||||
args[3].toInt32());
|
||||
break;
|
||||
|
@ -1595,6 +1596,10 @@ bool jsb_register_yasio(se::Object* obj)
|
|||
YASIO_EXPORT_ENUM(YOPT_C_ENABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_DISABLE_MCAST);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_KCP_CONV);
|
||||
YASIO_EXPORT_ENUM(YOPT_C_MOD_FLAGS);
|
||||
|
||||
YASIO_EXPORT_ENUM(YCF_REUSEADDR);
|
||||
YASIO_EXPORT_ENUM(YCF_EXCLUSIVEADDRUSE);
|
||||
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECT_RESPONSE);
|
||||
YASIO_EXPORT_ENUM(YEK_CONNECTION_LOST);
|
||||
|
|
|
@ -27,7 +27,6 @@ SOFTWARE.
|
|||
#ifndef YASIO__SHARED_MUTEX_HPP
|
||||
#define YASIO__SHARED_MUTEX_HPP
|
||||
|
||||
|
||||
#include "yasio/compiler/feature_test.hpp"
|
||||
|
||||
/// The shared_mutex workaround on c++11
|
||||
|
@ -59,12 +58,12 @@ SOFTWARE.
|
|||
# define yasio__smtx_unlock_exclusive(rwlock) pthread_rwlock_unlock(rwlock)
|
||||
# endif
|
||||
# define yaso__throw_error(e) throw std::system_error(std::make_error_code(e), "")
|
||||
# include <mutex>
|
||||
|
||||
// CLASS TEMPLATE shared_lock
|
||||
namespace cxx17
|
||||
{
|
||||
class shared_mutex
|
||||
{
|
||||
class shared_mutex {
|
||||
public:
|
||||
typedef yasio__smtx_t* native_handle_type;
|
||||
|
||||
|
@ -117,8 +116,7 @@ private:
|
|||
yasio__smtx_t _Myhandle; // the lock object
|
||||
};
|
||||
// CLASS TEMPLATE shared_lock
|
||||
template <class _Mutex> class shared_lock
|
||||
{ // shareable lock
|
||||
template <class _Mutex> class shared_lock { // shareable lock
|
||||
public:
|
||||
using mutex_type = _Mutex;
|
||||
|
||||
|
@ -129,12 +127,17 @@ public:
|
|||
_Mtx.lock_shared();
|
||||
}
|
||||
|
||||
explicit shared_lock(mutex_type& _Mtx, YASIO__STD defer_lock_t) : _Pmtx(YASIO__STD addressof(_Mtx)), _Owns(false) {} // // construct with unlocked mutex
|
||||
|
||||
explicit shared_lock(mutex_type& _Mtx, YASIO__STD try_to_lock_t)
|
||||
: _Pmtx(YASIO__STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared()) {} // construct with mutex and try to lock shared
|
||||
|
||||
explicit shared_lock(mutex_type& _Mtx, YASIO__STD adopt_lock_t) : _Pmtx(YASIO__STD addressof(_Mtx)), _Owns(true) {} // construct with mutex and adopt owership
|
||||
|
||||
~shared_lock()
|
||||
{
|
||||
if (_Owns)
|
||||
{
|
||||
_Pmtx->unlock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
shared_lock(shared_lock&& _Other) : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns)
|
||||
|
@ -146,9 +149,7 @@ public:
|
|||
shared_lock& operator=(shared_lock&& _Right)
|
||||
{
|
||||
if (_Owns)
|
||||
{
|
||||
_Pmtx->unlock_shared();
|
||||
}
|
||||
|
||||
_Pmtx = _Right._Pmtx;
|
||||
_Owns = _Right._Owns;
|
||||
|
|
|
@ -152,7 +152,7 @@ uint32_t ibstream_view::read_u24()
|
|||
|
||||
cxx17::string_view ibstream_view::read_v()
|
||||
{
|
||||
int count = read_ix<>();
|
||||
int count = read_ix<int>();
|
||||
return read_bytes(count);
|
||||
}
|
||||
|
||||
|
@ -179,10 +179,9 @@ void ibstream_view::read_bytes(void* oav, int len)
|
|||
|
||||
cxx17::string_view ibstream_view::read_bytes(int len)
|
||||
{
|
||||
cxx17::string_view sv;
|
||||
if (len > 0)
|
||||
sv = cxx17::string_view(consume(len), len);
|
||||
return sv;
|
||||
return cxx17::string_view(consume(len), len);
|
||||
return cxx17::string_view{};
|
||||
}
|
||||
|
||||
const char* ibstream_view::consume(size_t size)
|
||||
|
|
Loading…
Reference in New Issue