diff --git a/CronosAgent.c b/CronosAgent.c index ebe76c6..d912aa6 100644 --- a/CronosAgent.c +++ b/CronosAgent.c @@ -576,13 +576,13 @@ int main(int argc, const char* argv[]) if (flags & REWIND_FLAG_REAL_TIME_1) { - PushData(ringBuffers + 0, number, incomingBuffer->data, length); + PokeData(ringBuffers + 0, number, incomingBuffer->data, length); continue; } if (flags & REWIND_FLAG_REAL_TIME_2) { - PushData(ringBuffers + 1, number, incomingBuffer->data, length); + PokeData(ringBuffers + 1, number, incomingBuffer->data, length); continue; } diff --git a/RingBuffer.c b/RingBuffer.c index 60f9c0c..b5c22aa 100644 --- a/RingBuffer.c +++ b/RingBuffer.c @@ -3,12 +3,12 @@ #include #include -void PushData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length) +void PokeData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length) { number %= BUFFER_LENGTH; - buffer->delay += (buffer->flags == 0); // Postpone processing if buffer empty - buffer->flags |= (1 << number); // Set processing flag for the record + buffer->delay += buffer->marks == 0; // Postpone processing if buffer empty + buffer->marks |= 1 << number; // Set processing flag for the record struct BufferRecord* record = buffer->records + number; @@ -18,7 +18,7 @@ void PushData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* address) { - if (buffer->flags == 0) + if (buffer->marks == 0) { // Nothing to process return; @@ -31,17 +31,17 @@ void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* ad return; } - size_t mask = (1 << buffer->pointer); + size_t mark = (1 << buffer->index); - if (buffer->flags & mask) + if (buffer->marks & mark) { // Transmit scheduled data - struct BufferRecord* record = buffer->records + buffer->pointer; + struct BufferRecord* record = buffer->records + buffer->index; sendto(handle, record->data, record->length, 0, (struct sockaddr*)address, sizeof(struct sockaddr_in)); // Clear processing flag - buffer->flags ^= mask; + buffer->marks ^= mark; } - buffer->pointer ++; - buffer->pointer %= BUFFER_LENGTH; + buffer->index ++; + buffer->index %= BUFFER_LENGTH; } diff --git a/RingBuffer.h b/RingBuffer.h index 748609d..a50e813 100644 --- a/RingBuffer.h +++ b/RingBuffer.h @@ -21,13 +21,13 @@ struct BufferRecord struct RingBuffer { - size_t flags; + size_t marks; size_t delay; - size_t pointer; + size_t index; struct BufferRecord records[BUFFER_LENGTH]; }; -void PushData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length); +void PokeData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length); void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* address); #ifdef __cplusplus