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