XDispatch 0.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
timer.h
Go to the documentation of this file.
00001 
00002 /*
00003 * Copyright (c) 2011-2013 MLBA-Team. All rights reserved.
00004 *
00005 * @MLBA_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 *
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 *
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 * @MLBA_OPEN_LICENSE_HEADER_END@
00020 */
00021 
00022 
00023 #ifndef XDISPATCH_TIMER_H_
00024 #define XDISPATCH_TIMER_H_
00025 
00031 #ifndef __XDISPATCH_INDIRECT__
00032 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00033 #endif
00034 
00035 __XDISPATCH_BEGIN_NAMESPACE
00036 
00046 class XDISPATCH_EXPORT timer : public source {
00047 
00048     public:
00056         timer(uint64_t interval, const xdispatch::queue& target = global_queue(), const time& starting = time_now);
00057         timer(const timer&);
00058         ~timer();
00059 
00065         void interval(uint64_t);
00071         void latency(uint64_t);
00078         inline void start(){ resume(); }
00085         inline void stop(){ suspend(); }
00090         static timer* current();
00095         static void single_shot(dispatch_time_t, const xdispatch::queue&, xdispatch::operation*);
00100         static void single_shot(struct tm*, const xdispatch::queue&, xdispatch::operation*);
00101 #ifdef XDISPATCH_HAS_BLOCKS
00102 
00106         static void single_shot(dispatch_time_t t, const xdispatch::queue& q, dispatch_block_t b) {
00107             single_shot( t, q, new block_operation(b) );
00108         }
00113         static void single_shot(struct tm* t, const xdispatch::queue& q, dispatch_block_t b) {
00114             single_shot( t, q, new block_operation(b) );
00115         }
00116 #endif
00117 
00121         static void single_shot(dispatch_time_t t, const xdispatch::queue& q, const lambda_function& b) {
00122             single_shot( t, q, new function_operation(b) );
00123         }
00128         static void single_shot(struct tm* t, const xdispatch::queue& q, const lambda_function& b) {
00129             single_shot( t, q, new function_operation(b) );
00130         }
00131 
00132         timer& operator =(const timer&);
00133 
00134 };
00135 
00136 __XDISPATCH_END_NAMESPACE
00137 
00138 
00141 #endif /* XDISPATCH_TIMER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Jan 27 2013 21:21:52 for XDispatch by Doxygen 1.7.6.1
© 2010-2013 MLBA (about | privacy) All Rights reserved.