barrier_closure.h 966 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_BARRIER_CLOSURE_H_
  5. #define BASE_BARRIER_CLOSURE_H_
  6. #include "base/base_export.h"
  7. #include "base/callback.h"
  8. namespace base {
  9. // BarrierClosure executes |done_closure| after it has been invoked
  10. // |num_closures| times.
  11. //
  12. // If |num_closures| is 0, |done_closure| is executed immediately.
  13. //
  14. // BarrierClosure is thread-safe - the count of remaining closures is
  15. // maintained as a base::AtomicRefCount. |done_closure| will be run on
  16. // the thread that calls the final Run() on the returned closures.
  17. //
  18. // |done_closure| is also cleared on the final calling thread.
  19. BASE_EXPORT RepeatingClosure BarrierClosure(int num_closures,
  20. OnceClosure done_closure);
  21. } // namespace base
  22. #endif // BASE_BARRIER_CLOSURE_H_