static void _process_websocket_op_request(void)
{
- websocket_op_s *op = op_queue.pop();
+ RET_IF(op_queue.empty(), "operation queue is NULL");
+
+ websocket_op_s *op = op_queue.front();
+ op_queue.pop();
RET_IF(op == NULL, "op is NULL");
if (!op->ws) {
websocket_data_s *wd = NULL;
int bytes = 0;
- if (!ws->write_buffer)
+ if (!ws->write_buffer || ws->write_buffer->empty())
return bytes;
- if ((wd = ws->write_buffer->pop())) {
+ wd = ws->write_buffer->front();
+ ws->write_buffer->pop();
+ if (wd) {
unsigned char *out = (unsigned char *)calloc(LWS_PRE + wd->len,
sizeof(unsigned char));
memcpy(out + LWS_PRE, wd->buf, wd->len);
while (!ws->recv_buffer->empty() && len > 0) {
wd = ws->recv_buffer->front();
if (wd == nullptr) {
- ws->recv_buffer->erase();
+ ws->recv_buffer->pop();
return bytes;
}
bytes += read_len;
if (read_len >= wd->len) {
- ws->recv_buffer->erase();
+ ws->recv_buffer->pop();
bool last = wd->last;
__destroy_websocket_data(wd);
wd = NULL;
_queue.push(element);
}
- T pop()
+ void pop()
{
std::lock_guard<std::mutex> lock_guard(_q_mutex);
if (_queue.empty())
- return NULL;
-
- T element = _queue.front();
- _queue.pop();
- return element;
- }
-
- void erase() // void pop
- {
- std::lock_guard<std::mutex> lock_guard(_q_mutex);
+ return;
_queue.pop();
}
*read_len = bytes;
if (dp_info.second == 0)
- mRecvDataPathList.erase();
+ mRecvDataPathList.pop();
return VINE_ERROR_NONE;
}
{
vine_event_queue_s *event_fd_handle = (vine_event_queue_s *)event_fd;
- vine_event *event;
- while ( (event = event_fd_handle->event_queue.pop()) != NULL) {
- if (event->free_func)
+ vine_event *event = NULL;
+ while(!event_fd_handle->event_queue.empty()) {
+ event = event_fd_handle->event_queue.front();
+ if (event && event->free_func)
event->free_func(event->event_data);
+ event_fd_handle->event_queue.pop();
+ free(event);
}
+
if (event_fd_handle->fd >= 0)
close(event_fd_handle->fd);
delete event_fd_handle;
VINE_LOGD("eventfd counter: %lld", u);
- while (u--) {
- vine_event *event = event_fd_handle->event_queue.pop();
+ while (u-- && !event_fd_handle->event_queue.empty()) {
+ vine_event *event = event_fd_handle->event_queue.front();
+ event_fd_handle->event_queue.pop();
if (event == NULL) {
VINE_LOGE("vine event queue is empty");
- return VINE_ERROR_INVALID_OPERATION;
+ continue;
}
VINE_LOGD("Vine event[%p]", event);
if (event->handler == NULL) {
VINE_LOGI("No event handler");
- return VINE_ERROR_NONE;
+ continue;
}
event->handler(event->event_data, event->user_data);