uint32_t _process( struct iothreads * parent, struct iothread * thread, struct taskqueue * doqueue ) { uint32_t nprocess = 0; // 交换任务队列 msgqueue_swap( thread->queue, doqueue ); // 获取最大任务数 nprocess = QUEUE_COUNT(taskqueue)(doqueue); // 处理任务 for( ; QUEUE_COUNT(taskqueue)(doqueue) > 0; ) { struct task task; QUEUE_POP(taskqueue)( doqueue, &task ); // 网络任务处理 if ( task.type == eTaskType_User ) { parent->processor( parent->context, thread->index, task.utype, task.taskdata ); } else if ( task.type == eTaskType_Data ) { parent->processor( parent->context, thread->index, task.utype, (void *)(task.data) ); } } return nprocess; }
uint32_t _process( struct iothreads * parent, struct iothread * thread, struct taskqueue * doqueue ) { uint32_t nprocess = 0; // 交换任务队列 msgqueue_swap( thread->queue, doqueue ); // 获取最大任务数 nprocess = QUEUE_COUNT(taskqueue)(doqueue); // 处理任务 while ( QUEUE_COUNT(taskqueue)(doqueue) > 0 ) { struct task task; void * data = NULL; QUEUE_POP(taskqueue)( doqueue, &task ); switch ( task.type ) { case eTaskType_Null : { // 空命令 continue; } break; case eTaskType_User : { // 用户命令 data = task.taskdata; } break; case eTaskType_Data : { // 数据命令 data = (void *)(task.data); } break; } // 回调 parent->method( parent->context, thread->index, task.utype, data ); } return nprocess; }