Skip to content

Commit c73f674

Browse files
committed
Sync v3.22.1 finally finally (#116)
* Update README.md * Optimize sources. * Rename io_service's member transports_dypool_ to transports_pool_ * Tidy sources. * Update description. * Fix compile issues for HEADER ONLY support. * Fix compile issues with YASIO_HAVE_KCP for HEADER ONLY support. * Sync kcptest.cpp * Remove unused definations * Optimize includes for YASIO_HEADER_ONLY Use inline namespace avoid conflicit on Apple platform.
1 parent d3d6f2e commit c73f674

File tree

18 files changed

+754
-741
lines changed

18 files changed

+754
-741
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yasio - *Y*et *A*nother *S*ocket *IO* service
22
[![Build Status](https://travis-ci.org/halx99/yasio.svg?branch=master)](https://travis-ci.org/halx99/yasio)
3-
[![Release](https://img.shields.io/badge/release-v3.22.0-blue.svg)](https://github.com/halx99/yasio/releases)
3+
[![Release](https://img.shields.io/badge/release-v3.22.1-blue.svg)](https://github.com/halx99/yasio/releases)
44
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
55
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/halx99/yasio/blob/master/LICENSE)
66
[![GitHub stars](https://img.shields.io/github/stars/halx99/yasio.svg?label=Stars)](https://github.com/halx99/yasio)

msvc/cpptest/kcptest.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
#include <stdlib.h>
33
#include <string.h>
44

5-
#if defined(YASIO_IOCP)
6-
# include "yasio/experimental/yasio_iocp.h"
7-
#elif defined(YASIO_POLL)
8-
# include "yasio/experimental/yasio_poll.h"
9-
#elif defined(YASIO_EPOLL)
10-
# include "yasio/experimental/yasio_epoll.h"
11-
#else
12-
# include "yasio/yasio.h"
13-
#endif
14-
#include "yasio/ibstream.h"
15-
#include "yasio/obstream.h"
5+
#include "yasio/yasio.hpp"
6+
#include "yasio/ibstream.hpp"
7+
#include "yasio/obstream.hpp"
168

179
#if defined(_WIN32)
1810
# include <Shlwapi.h>

version.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
yasio-3.22.0
2-
1. Add kcp support.
3-
2. Change obsteeam.pop behavoir, see: https://github.com/halx99/yasio/wiki/obstream#Encapsulate-Packet
4-
3. Remove unused send timeout.
5-
4. Remove duplicated macro YOPT_CONNECT_TIMEOUT for script bindings.
1+
yasio-3.22.1
2+
1. Add -DYASIO_HEADER_ONLY to enable core(c++) implemention header only support.
3+
2. Other code optimizing.

yasio/detail/config.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ SOFTWARE.
2929
#ifndef YASIO__CONFIG_HPP
3030
#define YASIO__CONFIG_HPP
3131

32-
// Uncomment or add -DYASIO__HEADER_ONLY to enable yasio core implementation header only
33-
// #define YASIO__HEADER_ONLY 1
32+
// Uncomment or add -DYASIO_HEADER_ONLY to enable yasio core implementation header only
33+
// #define YASIO_HEADER_ONLY 1
3434

35-
#if defined(YASIO__HEADER_ONLY)
36-
#define YASIO__DECL inline
35+
#if defined(YASIO_HEADER_ONLY)
36+
# define YASIO__DECL inline
3737
#else
38-
#define YASIO__DECL
38+
# define YASIO__DECL
3939
#endif
4040

41+
#if defined(_MSC_VER) && _MSC_VER <= 1800
42+
# define YASIO__HAVE_NS_INLINE 0
43+
# define YASIO__NS_INLINE
44+
#else
45+
# define YASIO__HAVE_NS_INLINE 1
46+
# define YASIO__NS_INLINE inline
4147
#endif
4248

49+
#endif

yasio/detail/object_pool.cpp

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1+
//////////////////////////////////////////////////////////////////////////////////////////
2+
// A cross platform socket APIs, support ios & android & wp8 & window store
3+
// universal app
4+
//////////////////////////////////////////////////////////////////////////////////////////
5+
/*
6+
The MIT License (MIT)
7+
8+
Copyright (c) 2012-2019 halx99
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
*/
128
// object_pool.cpp: a simple & high-performance object pool implementation v1.3
229

3-
#if !defined(YASIO__OBJECT_POOL_CPP)
4-
# define YASIO__OBJECT_POOL_CPP
30+
#ifndef YASIO__OBJECT_POOL_CPP
31+
#define YASIO__OBJECT_POOL_CPP
532

6-
# if !defined(YASIO_OBJECT_POOL_HEADER_ONLY)
7-
# include "object_pool.h"
8-
# endif
33+
#if !defined(YASIO_OBJECT_POOL_HEADER_ONLY)
34+
# include "object_pool.h"
35+
#endif
936

10-
# define OBJECT_POOL_PREALLOCATE 1
37+
#define OBJECT_POOL_PREALLOCATE 1
1138

1239
namespace yasio
1340
{
@@ -17,19 +44,19 @@ namespace gc
1744
namespace detail
1845
{
1946

20-
# define POOL_FL_BEGIN(chunk) reinterpret_cast<free_link_node *>(chunk->data)
47+
#define POOL_FL_BEGIN(chunk) reinterpret_cast<free_link_node *>(chunk->data)
2148

2249
object_pool::object_pool(size_t element_size, size_t element_count)
2350
: free_link_(nullptr), chunk_(nullptr), element_size_(element_size),
2451
element_count_(element_count)
25-
# ifdef _DEBUG
52+
#ifdef _DEBUG
2653
,
2754
allocated_count_(0)
28-
# endif
55+
#endif
2956
{
30-
# if OBJECT_POOL_PREALLOCATE
57+
#if OBJECT_POOL_PREALLOCATE
3158
release(allocate_from_process_heap()); // preallocate 1 chunk
32-
# endif
59+
#endif
3360
}
3461

3562
object_pool::~object_pool(void) { this->purge(); }
@@ -55,9 +82,9 @@ void object_pool::cleanup(void)
5582

5683
this->free_link_ = POOL_FL_BEGIN(this->chunk_);
5784

58-
# if defined(_DEBUG)
85+
#if defined(_DEBUG)
5986
this->allocated_count_ = 0;
60-
# endif
87+
#endif
6188
}
6289

6390
void object_pool::purge(void)
@@ -74,9 +101,9 @@ void object_pool::purge(void)
74101

75102
free_link_ = nullptr;
76103

77-
# if defined(_DEBUG)
104+
#if defined(_DEBUG)
78105
allocated_count_ = 0;
79-
# endif
106+
#endif
80107
}
81108

82109
void *object_pool::get(void)
@@ -95,18 +122,18 @@ void object_pool::release(void *_Ptr)
95122
ptr->next = this->free_link_;
96123
this->free_link_ = ptr;
97124

98-
# if defined(_DEBUG)
125+
#if defined(_DEBUG)
99126
--this->allocated_count_;
100-
# endif
127+
#endif
101128
}
102129

103130
void *object_pool::allocate_from_process_heap(void)
104131
{
105132
chunk_link new_chunk =
106133
(chunk_link)malloc(sizeof(chunk_link_node) + element_size_ * element_count_);
107-
# ifdef _DEBUG
134+
#ifdef _DEBUG
108135
::memset(new_chunk, 0x00, sizeof(chunk_link_node));
109-
# endif
136+
#endif
110137
tidy_chunk(new_chunk)->next = nullptr;
111138

112139
// link the new_chunk
@@ -117,19 +144,19 @@ void *object_pool::allocate_from_process_heap(void)
117144
auto ptr = POOL_FL_BEGIN(new_chunk);
118145
this->free_link_ = ptr->next;
119146

120-
# if defined(_DEBUG)
147+
#if defined(_DEBUG)
121148
++this->allocated_count_;
122-
# endif
149+
#endif
123150
return reinterpret_cast<void *>(ptr);
124151
}
125152

126153
void *object_pool::allocate_from_chunk(void)
127154
{
128155
free_link_node *ptr = this->free_link_;
129156
this->free_link_ = ptr->next;
130-
# if defined(_DEBUG)
157+
#if defined(_DEBUG)
131158
++this->allocated_count_;
132-
# endif
159+
#endif
133160
return reinterpret_cast<void *>(ptr);
134161
}
135162

@@ -151,8 +178,3 @@ object_pool::free_link_node *object_pool::tidy_chunk(chunk_link chunk)
151178
} // namespace yasio
152179

153180
#endif // YASIO__OBJECT_POOL_CPP
154-
/*
155-
* Copyright (c) 2012-2019 by HALX99, ALL RIGHTS RESERVED.
156-
* Consult your license regarding permissions and restrictions.
157-
* V1.3:2019
158-
**/

0 commit comments

Comments
 (0)