mirror of
				git://erdgeist.org/opentracker
				synced 2025-11-04 11:53:22 +08:00 
			
		
		
		
	Reflect new task-classes model in mutex queue
This commit is contained in:
		
							parent
							
								
									44a674c9df
								
							
						
					
					
						commit
						9cd6e355be
					
				
							
								
								
									
										11
									
								
								ot_mutex.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ot_mutex.c
									
									
									
									
									
								
							@ -182,7 +182,7 @@ void mutex_workqueue_canceltask( int64 socket ) {
 | 
				
			|||||||
  MTX_DBG( "canceltask unlocked.\n" );
 | 
					  MTX_DBG( "canceltask unlocked.\n" );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ot_taskid mutex_workqueue_poptask( ot_tasktype tasktype ) {
 | 
					ot_taskid mutex_workqueue_poptask( ot_tasktype *tasktype ) {
 | 
				
			||||||
  struct ot_task * task;
 | 
					  struct ot_task * task;
 | 
				
			||||||
  ot_taskid taskid = 0;
 | 
					  ot_taskid taskid = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -194,13 +194,14 @@ ot_taskid mutex_workqueue_poptask( ot_tasktype tasktype ) {
 | 
				
			|||||||
  while( !taskid ) {
 | 
					  while( !taskid ) {
 | 
				
			||||||
    /* Skip to the first unassigned task this worker wants to do */
 | 
					    /* Skip to the first unassigned task this worker wants to do */
 | 
				
			||||||
    task = tasklist;
 | 
					    task = tasklist;
 | 
				
			||||||
    while( task && ( task->tasktype != tasktype ) && ( task->taskid ) )
 | 
					    while( task && ( ( TASK_MASK & task->tasktype ) != *tasktype ) && ( task->taskid ) )
 | 
				
			||||||
      task = task->next;
 | 
					      task = task->next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If we found an outstanding task, assign a taskid to it
 | 
					    /* If we found an outstanding task, assign a taskid to it
 | 
				
			||||||
       and leave the loop */
 | 
					       and leave the loop */
 | 
				
			||||||
    if( task ) {
 | 
					    if( task ) {
 | 
				
			||||||
      task->taskid = taskid = ++next_free_taskid;
 | 
					      task->taskid = taskid = ++next_free_taskid;
 | 
				
			||||||
 | 
					      *tasktype = task->tasktype;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      /* Wait until the next task is being fed */
 | 
					      /* Wait until the next task is being fed */
 | 
				
			||||||
      MTX_DBG( "poptask cond waits.\n" );
 | 
					      MTX_DBG( "poptask cond waits.\n" );
 | 
				
			||||||
@ -231,7 +232,7 @@ int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iove
 | 
				
			|||||||
  if( task ) {
 | 
					  if( task ) {
 | 
				
			||||||
    task->iovec_entries = iovec_entries;
 | 
					    task->iovec_entries = iovec_entries;
 | 
				
			||||||
    task->iovec         = iovec;
 | 
					    task->iovec         = iovec;
 | 
				
			||||||
    task->tasktype      = OT_TASKTYPE_DONE;
 | 
					    task->tasktype      = TASK_DONE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Release lock */
 | 
					  /* Release lock */
 | 
				
			||||||
@ -253,10 +254,10 @@ int64 mutex_workqueue_popresult( int *iovec_entries, struct iovec ** iovec ) {
 | 
				
			|||||||
  MTX_DBG( "popresult locked.\n" );
 | 
					  MTX_DBG( "popresult locked.\n" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  task = &tasklist;
 | 
					  task = &tasklist;
 | 
				
			||||||
  while( *task && ( (*task)->tasktype != OT_TASKTYPE_DONE ) )
 | 
					  while( *task && ( (*task)->tasktype != TASK_DONE ) )
 | 
				
			||||||
    task = &(*task)->next;
 | 
					    task = &(*task)->next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if( *task && ( (*task)->tasktype == OT_TASKTYPE_DONE ) ) {
 | 
					  if( *task && ( (*task)->tasktype == TASK_DONE ) ) {
 | 
				
			||||||
    struct ot_task *ptask = *task;
 | 
					    struct ot_task *ptask = *task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    *iovec_entries = (*task)->iovec_entries;
 | 
					    *iovec_entries = (*task)->iovec_entries;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user