Google APIs Client Library for C++
|
00001 /* 00002 * \copyright Copyright 2013 Google Inc. All Rights Reserved. 00003 * \license @{ 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 * @} 00018 */ 00019 #ifndef THREAD_EXECUTOR_H_ 00020 #define THREAD_EXECUTOR_H_ 00021 00022 #include "googleapis/base/macros.h" 00023 namespace googleapis { 00024 00025 class Closure; 00026 00027 namespace thread { 00028 00029 class Executor { 00030 public: 00031 Executor(); 00032 virtual ~Executor(); 00033 00034 virtual int num_pending_closures() const = 0; 00035 virtual void Add(Closure* callback) = 0; 00036 virtual bool TryAdd(Closure* closure) = 0; 00037 00038 // Caller retains ownership. 00039 void SetDefaultExecutor(Executor* executor); 00040 static Executor* DefaultExecutor(); 00041 00042 private: 00043 DISALLOW_COPY_AND_ASSIGN(Executor); 00044 }; 00045 00046 // Immediately executes closures without using threads. 00047 // Caller should delete when done with it. 00048 Executor* NewInlineExecutor(); 00049 00050 // Ownership is maintained internally by the Executor itself. 00051 Executor* SingletonInlineExecutor(); 00052 00053 } // namespace thread 00054 00055 } // namespace googleapis 00056 #endif // THREAD_EXECUTOR_H_