Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108326
b: refs/heads/master
c: 39d2f1a
h: refs/heads/master
v: v3
  • Loading branch information
David Chinner authored and Lachlan McIlroy committed Aug 13, 2008
1 parent 7a59bc6 commit f1c5327
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b4dd330b9e0c9c78ebff754e72563b148f05e9e0
refs/heads/master: 39d2f1ab2a36ac527a6c41cfe689f50c239eaca3
45 changes: 45 additions & 0 deletions trunk/include/linux/completion.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,49 @@ extern void complete_all(struct completion *);

#define INIT_COMPLETION(x) ((x).done = 0)


/**
* try_wait_for_completion - try to decrement a completion without blocking
* @x: completion structure
*
* Returns: 0 if a decrement cannot be done without blocking
* 1 if a decrement succeeded.
*
* If a completion is being used as a counting completion,
* attempt to decrement the counter without blocking. This
* enables us to avoid waiting if the resource the completion
* is protecting is not available.
*/
static inline bool try_wait_for_completion(struct completion *x)
{
int ret = 1;

spin_lock_irq(&x->wait.lock);
if (!x->done)
ret = 0;
else
x->done--;
spin_unlock_irq(&x->wait.lock);
return ret;
}

/**
* completion_done - Test to see if a completion has any waiters
* @x: completion structure
*
* Returns: 0 if there are waiters (wait_for_completion() in progress)
* 1 if there are no waiters.
*
*/
static inline bool completion_done(struct completion *x)
{
int ret = 1;

spin_lock_irq(&x->wait.lock);
if (!x->done)
ret = 0;
spin_unlock_irq(&x->wait.lock);
return ret;
}

#endif

0 comments on commit f1c5327

Please sign in to comment.