• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

I_RecProcess.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   Public RecProcess declarations
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef _I_REC_PROCESS_H_
00025 #define _I_REC_PROCESS_H_
00026 
00027 #include "I_RecCore.h"
00028 #include "I_EventSystem.h"
00029 
00030 
00031 //-------------------------------------------------------------------------
00032 // Initialization/Starting
00033 //-------------------------------------------------------------------------
00034 int RecProcessInit(RecModeT mode_type, Diags * diags = NULL);
00035 int RecProcessInitMessage(RecModeT mode_type);
00036 int RecProcessStart(void);
00037 
00038 //-------------------------------------------------------------------------
00039 // Setters for manipulating internal sleep intervals
00040 //-------------------------------------------------------------------------
00041 void RecProcess_set_raw_stat_sync_interval_ms(int ms);
00042 void RecProcess_set_config_update_interval_ms(int ms);
00043 void RecProcess_set_remote_sync_interval_ms(int ms);
00044 
00045 //-------------------------------------------------------------------------
00046 // RawStat Registration
00047 //-------------------------------------------------------------------------
00048 RecRawStatBlock *RecAllocateRawStatBlock(int num_stats);
00049 
00050 int _RecRegisterRawStat(RecRawStatBlock * rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, RecRawStatSyncCb sync_cb);
00051 #define RecRegisterRawStat(rsb, rec_type, name, data_type, persist_type, id, sync_cb) \
00052   _RecRegisterRawStat((rsb), (rec_type), (name), (data_type), REC_PERSISTENCE_TYPE(persist_type), (id), (sync_cb))
00053 
00054 // RecRawStatRange* RecAllocateRawStatRange (int num_buckets);
00055 
00056 // int RecRegisterRawStatRange (RecRawStatRange *rsr,
00057 //                           RecT rec_type,
00058 //                           char *name,
00059 //                           RecPersistT persist_type,
00060 //                           int id,
00061 //                           RecInt min,
00062 //                           RecInt max);
00063 
00064 
00065 //-------------------------------------------------------------------------
00066 // Predefined RawStat Callbacks
00067 //-------------------------------------------------------------------------
00068 int RecRawStatSyncSum(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00069 int RecRawStatSyncCount(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00070 int RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00071 int RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00072 int RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type,
00073                                          RecData * data, RecRawStatBlock * rsb, int id);
00074 int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00075 
00076 
00077 //-------------------------------------------------------------------------
00078 // RawStat Setting/Getting
00079 //-------------------------------------------------------------------------
00080 
00081 // Note: The following RecIncrRawStatXXX calls are fast and don't
00082 // require any ink_atomic_xxx64()'s to be executed.  Use these RawStat
00083 // functions over other RawStat functions whenever possible.
00084 inline int RecIncrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1);
00085 inline int RecIncrRawStatSum(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1);
00086 inline int RecIncrRawStatCount(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1);
00087 int RecIncrRawStatBlock(RecRawStatBlock * rsb, EThread * ethread, RecRawStat * stat_array);
00088 
00089 int RecSetRawStatSum(RecRawStatBlock * rsb, int id, int64_t data);
00090 int RecSetRawStatCount(RecRawStatBlock * rsb, int id, int64_t data);
00091 int RecSetRawStatBlock(RecRawStatBlock * rsb, RecRawStat * stat_array);
00092 
00093 int RecGetRawStatSum(RecRawStatBlock * rsb, int id, int64_t * data);
00094 int RecGetRawStatCount(RecRawStatBlock * rsb, int id, int64_t * data);
00095 
00096 
00097 //-------------------------------------------------------------------------
00098 // Global RawStat Items (e.g. same as above, but no thread-local behavior)
00099 //-------------------------------------------------------------------------
00100 int RecIncrGlobalRawStat(RecRawStatBlock * rsb, int id, int64_t incr = 1);
00101 int RecIncrGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t incr = 1);
00102 int RecIncrGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t incr = 1);
00103 
00104 int RecSetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t data);
00105 int RecSetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t data);
00106 
00107 int RecGetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t * data);
00108 int RecGetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t * data);
00109 
00110 RecRawStat *RecGetGlobalRawStatPtr(RecRawStatBlock * rsb, int id);
00111 int64_t *RecGetGlobalRawStatSumPtr(RecRawStatBlock * rsb, int id);
00112 int64_t *RecGetGlobalRawStatCountPtr(RecRawStatBlock * rsb, int id);
00113 
00114 
00115 //-------------------------------------------------------------------------
00116 // RecIncrRawStatXXX
00117 //-------------------------------------------------------------------------
00118 // inlined functions that are used very frequently.
00119 // FIXME: move it to Inline.cc
00120 inline RecRawStat *
00121 raw_stat_get_tlp(RecRawStatBlock * rsb, int id, EThread * ethread)
00122 {
00123   ink_assert((id >= 0) && (id < rsb->max_stats));
00124   if (ethread == NULL) {
00125     ethread = this_ethread();
00126   }
00127   return (((RecRawStat *) ((char *) (ethread) + rsb->ethr_stat_offset)) + id);
00128 }
00129 
00130 inline int
00131 RecIncrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr)
00132 {
00133   RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
00134   tlp->sum += incr;
00135   tlp->count += 1;
00136   return REC_ERR_OKAY;
00137 }
00138 
00139 inline int
00140 RecDecrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t decr)
00141 {
00142   RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
00143   tlp->sum -= decr;
00144   tlp->count += 1;
00145   return REC_ERR_OKAY;
00146 }
00147 
00148 inline int
00149 RecIncrRawStatSum(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr)
00150 {
00151   RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
00152   tlp->sum += incr;
00153   return REC_ERR_OKAY;
00154 }
00155 
00156 inline int
00157 RecIncrRawStatCount(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr)
00158 {
00159   RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
00160   tlp->count += incr;
00161   return REC_ERR_OKAY;
00162 }
00163 
00164 #endif /* !_I_REC_PROCESS_H_ */

Generated by  doxygen 1.7.1