Merge with master

This commit is contained in:
lganzzzo 2020-03-30 04:34:22 +03:00
commit 7db40f5081
9 changed files with 64 additions and 59 deletions

View File

@ -85,10 +85,12 @@ void IOEventWorker::triggerWakeup() {
}
void IOEventWorker::setTriggerEvent(p_char8 eventPtr) {
(void) eventPtr;
// DO NOTHING
}
void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation, p_char8 eventPtr) {
(void) eventPtr;
auto& action = getCoroutineScheduledAction(coroutine);

View File

@ -90,7 +90,7 @@ void DefaultLogger::log(v_int32 priority, const std::string& tag, const std::str
}
if(m_config.timeFormat) {
time_t seconds = (time_t)std::chrono::duration_cast<std::chrono::seconds>(time).count();
time_t seconds = std::chrono::duration_cast<std::chrono::seconds>(time).count();
struct tm now;
localtime_r(&seconds, &now);
std::cout << std::put_time(&now, m_config.timeFormat);
@ -159,9 +159,9 @@ void Environment::destroy(){
WSACleanup();
#endif
}
void Environment::checkTypes(){
OATPP_ASSERT(sizeof(v_char8) == 1);
OATPP_ASSERT(sizeof(v_int16) == 2);
OATPP_ASSERT(sizeof(v_uint16) == 2);
@ -170,17 +170,17 @@ void Environment::checkTypes(){
OATPP_ASSERT(sizeof(v_uint32) == 4);
OATPP_ASSERT(sizeof(v_uint64) == 8);
OATPP_ASSERT(sizeof(v_float64) == 8);
v_int32 vInt32 = ~1;
v_int64 vInt64 = ~1;
v_uint32 vUInt32 = ~1;
v_uint64 vUInt64 = ~1;
OATPP_ASSERT(vInt32 < 0);
OATPP_ASSERT(vInt64 < 0);
OATPP_ASSERT(vUInt32 > 0);
OATPP_ASSERT(vUInt64 > 0);
}
void Environment::incObjects(){
@ -212,7 +212,7 @@ v_counter Environment::getObjectsCount(){
v_counter Environment::getObjectsCreated(){
return m_objectsCreated;
}
v_counter Environment::getThreadLocalObjectsCount(){
#ifndef OATPP_COMPAT_BUILD_NO_THREAD_LOCAL
return m_threadLocalObjectsCount;
@ -262,7 +262,7 @@ void Environment::log(v_int32 priority, const std::string& tag, const std::strin
m_logger->log(priority, tag, message);
}
}
void Environment::logFormatted(v_int32 priority, const std::string& tag, const char* message, ...) {
if(message == nullptr) {
message = "[null]";
@ -274,7 +274,7 @@ void Environment::logFormatted(v_int32 priority, const std::string& tag, const c
log(priority, tag, buffer);
va_end(args);
}
void Environment::registerComponent(const std::string& typeName, const std::string& componentName, void* component) {
auto& bucket = m_components[typeName];
auto it = bucket.find(componentName);
@ -283,7 +283,7 @@ void Environment::registerComponent(const std::string& typeName, const std::stri
}
bucket[componentName] = component;
}
void Environment::unregisterComponent(const std::string& typeName, const std::string& componentName) {
auto bucketIt = m_components.find(typeName);
if(bucketIt == m_components.end() || bucketIt->second.size() == 0) {
@ -324,11 +324,11 @@ void* Environment::getComponent(const std::string& typeName, const std::string&
}
return componentIt->second;
}
v_int64 Environment::getMicroTickCount(){
std::chrono::microseconds ms = std::chrono::duration_cast<std::chrono::microseconds>
(std::chrono::system_clock::now().time_since_epoch());
return ms.count();
}
}}

View File

@ -44,6 +44,7 @@ BufferOutputStream::~BufferOutputStream() {
}
v_io_size BufferOutputStream::write(const void *data, v_buff_size count, async::Action& action) {
(void) action;
(void) action;
@ -236,4 +237,4 @@ void BufferInputStream::setCurrentPosition(v_buff_size position) {
m_position = position;
}
}}}
}}}

View File

@ -29,7 +29,7 @@ namespace oatpp { namespace data{ namespace stream {
data::stream::DefaultInitializedContext ChunkedBuffer::DEFAULT_CONTEXT(data::stream::StreamType::STREAM_INFINITE);
const char* ChunkedBuffer::ERROR_ASYNC_FAILED_TO_WRITE_ALL_DATA = "ERROR_ASYNC_FAILED_TO_WRITE_ALL_DATA";
const char* const ChunkedBuffer::CHUNK_POOL_NAME = "ChunkedBuffer_Chunk_Pool";
const v_buff_size ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT = 11;
@ -64,7 +64,7 @@ void ChunkedBuffer::freeEntry(ChunkEntry* entry){
oatpp::base::memory::MemoryPool::free(entry->chunk);
delete entry;
}
v_io_size ChunkedBuffer::writeToEntry(ChunkEntry* entry,
const void *data,
v_buff_size count,
@ -80,7 +80,7 @@ v_io_size ChunkedBuffer::writeToEntry(ChunkEntry* entry,
return count;
}
}
v_io_size ChunkedBuffer::writeToEntryFrom(ChunkEntry* entry,
v_buff_size inChunkPos,
const void *data,
@ -98,7 +98,7 @@ v_io_size ChunkedBuffer::writeToEntryFrom(ChunkEntry* entry,
return count;
}
}
ChunkedBuffer::ChunkEntry* ChunkedBuffer::getChunkForPosition(ChunkEntry* fromChunk,
v_buff_size pos,
v_buff_size& outChunkPos)
@ -106,50 +106,50 @@ ChunkedBuffer::ChunkEntry* ChunkedBuffer::getChunkForPosition(ChunkEntry* fromCh
v_buff_size segIndex = pos >> CHUNK_ENTRY_SIZE_INDEX_SHIFT;
outChunkPos = pos - (segIndex << CHUNK_ENTRY_SIZE_INDEX_SHIFT);
auto curr = fromChunk;
for(v_buff_size i = 0; i < segIndex; i++){
curr = curr->next;
}
return curr;
}
v_io_size ChunkedBuffer::write(const void *data, v_buff_size count, async::Action& action){
(void) action;
if(count <= 0){
return 0;
}
if(m_lastEntry == nullptr){
obtainNewEntry();
}
ChunkEntry* entry = m_lastEntry;
v_buff_size pos = 0;
pos += writeToEntryFrom(entry, m_chunkPos, data, count, m_chunkPos);
if(m_chunkPos == 0){
entry = obtainNewEntry();
}
while (pos < count) {
pos += writeToEntry(entry, &((p_char8) data)[pos], count - pos, m_chunkPos);
if(m_chunkPos == 0){
entry = obtainNewEntry();
}
}
m_size += pos; // pos == count
return count;
}
void ChunkedBuffer::setOutputStreamIOMode(IOMode ioMode) {
@ -163,16 +163,16 @@ IOMode ChunkedBuffer::getOutputStreamIOMode() {
Context& ChunkedBuffer::getOutputStreamContext() {
return DEFAULT_CONTEXT;
}
v_io_size ChunkedBuffer::readSubstring(void *buffer,
v_buff_size pos,
v_buff_size count)
{
if(pos < 0 || pos >= m_size){
return 0;
}
v_buff_size countToRead;
if(pos + count > m_size){
countToRead = m_size - pos;
@ -185,34 +185,34 @@ v_io_size ChunkedBuffer::readSubstring(void *buffer,
v_buff_size lastChunkPos;
auto lastChunk = getChunkForPosition(firstChunk, firstChunkPos + countToRead, lastChunkPos);
v_io_size bufferPos = 0;
if(firstChunk != lastChunk){
v_buff_size countToCopy = CHUNK_ENTRY_SIZE - firstChunkPos;
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], (size_t)countToCopy);
bufferPos += countToCopy;
auto curr = firstChunk->next;
while (curr != lastChunk) {
std::memcpy(&((p_char8)buffer)[bufferPos], curr->chunk, CHUNK_ENTRY_SIZE);
bufferPos += CHUNK_ENTRY_SIZE;
curr = curr->next;
}
std::memcpy(&((p_char8)buffer)[bufferPos], lastChunk->chunk, (size_t)lastChunkPos);
} else {
v_buff_size countToCopy = lastChunkPos - firstChunkPos;
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], (size_t)countToCopy);
}
return countToRead;
}
oatpp::String ChunkedBuffer::getSubstring(v_buff_size pos, v_buff_size count){
auto str = oatpp::String((v_int32) count);
readSubstring(str->getData(), pos, count);
@ -242,7 +242,7 @@ bool ChunkedBuffer::flushToStream(OutputStream* stream){
}
oatpp::async::CoroutineStarter ChunkedBuffer::flushToStreamAsync(const std::shared_ptr<OutputStream>& stream) {
class FlushCoroutine : public oatpp::async::Coroutine<FlushCoroutine> {
private:
std::shared_ptr<ChunkedBuffer> m_chunkedBuffer;
@ -253,7 +253,7 @@ oatpp::async::CoroutineStarter ChunkedBuffer::flushToStreamAsync(const std::shar
data::buffer::InlineWriteData m_currData;
bool m_needInit;
public:
FlushCoroutine(const std::shared_ptr<ChunkedBuffer>& chunkedBuffer,
const std::shared_ptr<OutputStream>& stream)
: m_chunkedBuffer(chunkedBuffer)
@ -291,17 +291,17 @@ oatpp::async::CoroutineStarter ChunkedBuffer::flushToStreamAsync(const std::shar
}
}
Action writeCurrData() {
return m_stream->writeExactSizeDataAsyncInline(m_currData, Action::clone(m_nextAction));
}
};
return FlushCoroutine::start(shared_from_this(), stream);
}
std::shared_ptr<ChunkedBuffer::Chunks> ChunkedBuffer::getChunks() {
auto chunks = Chunks::createShared();
auto curr = m_firstEntry;
@ -323,19 +323,19 @@ v_buff_size ChunkedBuffer::getSize(){
}
void ChunkedBuffer::clear(){
ChunkEntry* curr = m_firstEntry;
while (curr != nullptr) {
ChunkEntry* next = curr->next;
freeEntry(curr);
curr = next;
}
m_size = 0;
m_chunkPos = 0;
m_firstEntry = nullptr;
m_lastEntry = nullptr;
}
}}}

View File

@ -46,6 +46,7 @@ void Beautifier::writeIndent(ConsistentOutputStream* outputStream) {
}
v_io_size Beautifier::write(const void *data, v_buff_size count, async::Action& action) {
(void) action;
(void) action;

View File

@ -78,6 +78,7 @@ void Serializer::serializeString(Serializer* serializer,
data::stream::ConsistentOutputStream* stream,
const data::mapping::type::AbstractObjectWrapper& polymorph)
{
(void) serializer;
(void) serializer;

View File

@ -120,7 +120,6 @@ private:
static void serializePrimitive(Serializer* serializer,
data::stream::ConsistentOutputStream* stream,
const data::mapping::type::AbstractObjectWrapper& polymorph){
(void) serializer;
if(polymorph){

View File

@ -48,4 +48,4 @@ v_int64 SimpleRetryPolicy::waitForMicroseconds(const Context& context) {
return m_delay;
}
}}}
}}}

View File

@ -37,6 +37,7 @@ std::shared_ptr<BufferBody> BufferBody::createShared(const oatpp::String& buffer
}
v_io_size BufferBody::read(void *buffer, v_buff_size count, async::Action& action) {
(void) action;
(void) action;
@ -73,4 +74,4 @@ v_buff_size BufferBody::getKnownSize() {
return m_buffer->getSize();
}
}}}}}
}}}}}