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

P_Freer.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
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 #if !defined(_P_Freer_h_)
00025 #define _P_Freer_h_
00026 
00027 #include "libts.h"
00028 #include "I_Tasks.h"
00029 
00030 // Note that these should not be used for memory that wishes to retain
00031 // NUMA socket affinity. We'll potentially return these on an arbitarily
00032 // selected processor/socket.
00033 
00034 template<class C> struct DeleterContinuation: public Continuation
00035 {
00036 public:                        // Needed by WinNT compiler (compiler bug)
00037   C * p;
00038   int dieEvent(int event, void *e)
00039   {
00040     (void) event;
00041     (void) e;
00042     if (p)
00043       delete p;
00044     delete this;
00045       return EVENT_DONE;
00046   }
00047   DeleterContinuation(C * ap):Continuation(new_ProxyMutex()), p(ap)
00048   {
00049     SET_HANDLER(&DeleterContinuation::dieEvent);
00050   }
00051 };
00052 
00053 template<class C> TS_INLINE void
00054 new_Deleter(C * ap, ink_hrtime t)
00055 {
00056   eventProcessor.schedule_in(new DeleterContinuation<C> (ap), t, ET_TASK);
00057 }
00058 
00059 template<class C> struct FreeCallContinuation: public Continuation
00060 {
00061 public:                        // Needed by WinNT compiler (compiler bug)
00062   C * p;
00063   int dieEvent(int event, void *e)
00064   {
00065     (void) event;
00066     (void) e;
00067     p->free();
00068     delete this;
00069       return EVENT_DONE;
00070   }
00071   FreeCallContinuation(C * ap):Continuation(NULL), p(ap)
00072   {
00073     SET_HANDLER(&FreeCallContinuation::dieEvent);
00074   }
00075 };
00076 
00077 template<class C> TS_INLINE void
00078 new_FreeCaller(C * ap, ink_hrtime t)
00079 {
00080   eventProcessor.schedule_in(new FreeCallContinuation<C> (ap), t, ET_TASK);
00081 }
00082 
00083 struct FreerContinuation;
00084 typedef int (FreerContinuation::*FreerContHandler) (int, void *);
00085 
00086 struct FreerContinuation: public Continuation
00087 {
00088   void *p;
00089 
00090   int dieEvent(int event, Event * e)
00091   {
00092     (void) event;
00093     (void) e;
00094     ats_free(p);
00095     delete this;
00096     return EVENT_DONE;
00097   }
00098 
00099   FreerContinuation(void *ap):Continuation(NULL), p(ap)
00100   {
00101     SET_HANDLER((FreerContHandler) & FreerContinuation::dieEvent);
00102   }
00103 };
00104 
00105 TS_INLINE void
00106 new_Freer(void *ap, ink_hrtime t)
00107 {
00108   eventProcessor.schedule_in(new FreerContinuation(ap), t, ET_TASK);
00109 }
00110 
00111 template<class C> struct DereferContinuation: public Continuation
00112 {
00113   C *p;
00114 
00115   int dieEvent(int, Event *)
00116   {
00117     p->refcount_dec();
00118     if (REF_COUNT_OBJ_REFCOUNT_DEC(p) == 0) {
00119       delete p;
00120     }
00121 
00122     delete this;
00123     return EVENT_DONE;
00124   }
00125 
00126   DereferContinuation(C * ap):Continuation(NULL), p(ap)
00127   {
00128     SET_HANDLER(&DereferContinuation::dieEvent);
00129   }
00130 };
00131 
00132 template<class C> TS_INLINE void
00133 new_Derefer(C * ap, ink_hrtime t)
00134 {
00135   eventProcessor.schedule_in(new DereferContinuation<C> (ap), t, ET_TASK);
00136 }
00137 
00138 #endif /* _Freer_h_ */

Generated by  doxygen 1.7.1