forked from mirrors/linux
		
	closures: closure_wait_event()
Like wait_event() - except, because it uses closures and closure waitlists it doesn't have the restriction on modifying task state inside the condition check, like wait_event() does. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Acked-by: Coly Li <colyli@suse.de>
This commit is contained in:
		
							parent
							
								
									bd0d22e41e
								
							
						
					
					
						commit
						ced58fc7ab
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		|  | @ -374,4 +374,26 @@ static inline void closure_call(struct closure *cl, closure_fn fn, | ||||||
| 	continue_at_nobarrier(cl, fn, wq); | 	continue_at_nobarrier(cl, fn, wq); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #define __closure_wait_event(waitlist, _cond)				\ | ||||||
|  | do {									\ | ||||||
|  | 	struct closure cl;						\ | ||||||
|  | 									\ | ||||||
|  | 	closure_init_stack(&cl);					\ | ||||||
|  | 									\ | ||||||
|  | 	while (1) {							\ | ||||||
|  | 		closure_wait(waitlist, &cl);				\ | ||||||
|  | 		if (_cond)						\ | ||||||
|  | 			break;						\ | ||||||
|  | 		closure_sync(&cl);					\ | ||||||
|  | 	}								\ | ||||||
|  | 	closure_wake_up(waitlist);					\ | ||||||
|  | 	closure_sync(&cl);						\ | ||||||
|  | } while (0) | ||||||
|  | 
 | ||||||
|  | #define closure_wait_event(waitlist, _cond)				\ | ||||||
|  | do {									\ | ||||||
|  | 	if (!(_cond))							\ | ||||||
|  | 		__closure_wait_event(waitlist, _cond);			\ | ||||||
|  | } while (0) | ||||||
|  | 
 | ||||||
| #endif /* _LINUX_CLOSURE_H */ | #endif /* _LINUX_CLOSURE_H */ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Kent Overstreet
						Kent Overstreet