Index: base/message_loop.h |
diff --git a/base/message_loop.h b/base/message_loop.h |
index dbe75a57f9f410ae1a672745c1daffdb8ee4ce37..070fd2cc4d91c2c4c93e87575cea0886636464b8 100644 |
--- a/base/message_loop.h |
+++ b/base/message_loop.h |
@@ -168,12 +168,20 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate { |
// PostTask(from_here, task) is equivalent to |
// PostDelayedTask(from_here, task, 0). |
// |
+ // The TryPostTask is meant for the cases where the calling thread cannot |
+ // block. If posting the task will block, the call returns false, the task |
+ // is not posted but the task is consumed anyways. |
+ // |
// NOTE: These methods may be called on any thread. The Task will be invoked |
// on the thread that executes MessageLoop::Run(). |
void PostTask( |
const tracked_objects::Location& from_here, |
const base::Closure& task); |
+ bool TryPostTask( |
+ const tracked_objects::Location& from_here, |
+ const base::Closure& task); |
+ |
void PostDelayedTask( |
const tracked_objects::Location& from_here, |
const base::Closure& task, |
@@ -437,7 +445,11 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate { |
// reset the value of pending_task->task. This is needed to ensure |
// that the posting call stack does not retain pending_task->task |
// beyond this function call. |
- void AddToIncomingQueue(base::PendingTask* pending_task); |
+ // If |use_try_lock| is true, The function fails if another thread is |
+ // queuing or dequeing at that moment. In that case the function returns |
+ // false. If |use_try_lock| is false there is no need to check the |
+ // return value. |
+ bool AddToIncomingQueue(base::PendingTask* pending_task, bool use_try_lock); |
// Load tasks from the incoming_queue_ into work_queue_ if the latter is |
// empty. The former requires a lock to access, while the latter is directly |