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

P_UnixEThread.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 /****************************************************************************
00025 
00026   P_UnixEThread.h
00027 
00028 
00029 
00030 *****************************************************************************/
00031 #ifndef _P_UnixEThread_h_
00032 #define _P_UnixEThread_h_
00033 
00034 #include "I_EThread.h"
00035 #include "I_EventProcessor.h"
00036 
00037 const int DELAY_FOR_RETRY = HRTIME_MSECONDS(10);
00038 
00039 TS_INLINE Event *
00040 EThread::schedule_spawn(Continuation * cont)
00041 {
00042   Event *e = EVENT_ALLOC(eventAllocator, this);
00043   return schedule(e->init(cont, 0, 0));
00044 }
00045 
00046 TS_INLINE Event *
00047 EThread::schedule_imm(Continuation * cont, int callback_event, void *cookie)
00048 {
00049   Event *e =::eventAllocator.alloc();
00050   e->callback_event = callback_event;
00051   e->cookie = cookie;
00052   return schedule(e->init(cont, 0, 0));
00053 }
00054 
00055 TS_INLINE Event *
00056 EThread::schedule_imm_signal(Continuation * cont, int callback_event, void *cookie)
00057 {
00058   Event *e =::eventAllocator.alloc();
00059   e->callback_event = callback_event;
00060   e->cookie = cookie;
00061   return schedule(e->init(cont, 0, 0), true);
00062 }
00063 
00064 TS_INLINE Event *
00065 EThread::schedule_at(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00066 {
00067   Event *e =::eventAllocator.alloc();
00068   e->callback_event = callback_event;
00069   e->cookie = cookie;
00070   return schedule(e->init(cont, t, 0));
00071 }
00072 
00073 TS_INLINE Event *
00074 EThread::schedule_in(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00075 {
00076   Event *e =::eventAllocator.alloc();
00077   e->callback_event = callback_event;
00078   e->cookie = cookie;
00079   return schedule(e->init(cont, ink_get_based_hrtime() + t, 0));
00080 }
00081 
00082 TS_INLINE Event *
00083 EThread::schedule_every(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00084 {
00085   Event *e =::eventAllocator.alloc();
00086   e->callback_event = callback_event;
00087   e->cookie = cookie;
00088   return schedule(e->init(cont, ink_get_based_hrtime() + t, t));
00089 }
00090 
00091 TS_INLINE Event *
00092 EThread::schedule(Event * e, bool fast_signal)
00093 {
00094   e->ethread = this;
00095   ink_assert(tt == REGULAR);
00096   if (e->continuation->mutex)
00097     e->mutex = e->continuation->mutex;
00098   else
00099     e->mutex = e->continuation->mutex = e->ethread->mutex;
00100   ink_assert(e->mutex.m_ptr);
00101   EventQueueExternal.enqueue(e, fast_signal);
00102   return e;
00103 }
00104 
00105 TS_INLINE Event *
00106 EThread::schedule_imm_local(Continuation * cont, int callback_event, void *cookie)
00107 {
00108   Event *e = EVENT_ALLOC(eventAllocator, this);
00109   e->callback_event = callback_event;
00110   e->cookie = cookie;
00111   return schedule_local(e->init(cont, 0, 0));
00112 }
00113 
00114 TS_INLINE Event *
00115 EThread::schedule_at_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00116 {
00117   Event *e = EVENT_ALLOC(eventAllocator, this);
00118   e->callback_event = callback_event;
00119   e->cookie = cookie;
00120   return schedule_local(e->init(cont, t, 0));
00121 }
00122 
00123 TS_INLINE Event *
00124 EThread::schedule_in_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00125 {
00126   Event *e = EVENT_ALLOC(eventAllocator, this);
00127   e->callback_event = callback_event;
00128   e->cookie = cookie;
00129   return schedule_local(e->init(cont, ink_get_based_hrtime() + t, 0));
00130 }
00131 
00132 TS_INLINE Event *
00133 EThread::schedule_every_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
00134 {
00135   Event *e = EVENT_ALLOC(eventAllocator, this);
00136   e->callback_event = callback_event;
00137   e->cookie = cookie;
00138   return schedule_local(e->init(cont, ink_get_based_hrtime() + t, t));
00139 }
00140 
00141 TS_INLINE Event *
00142 EThread::schedule_local(Event * e)
00143 {
00144   if (tt != REGULAR) {
00145     ink_assert(tt == DEDICATED);
00146     return eventProcessor.schedule(e, ET_CALL);
00147   }
00148   if (!e->mutex.m_ptr) {
00149     e->ethread = this;
00150     e->mutex = e->continuation->mutex;
00151   } else {
00152     ink_assert(e->ethread == this);
00153   }
00154   e->globally_allocated = false;
00155   EventQueueExternal.enqueue_local(e);
00156   return e;
00157 }
00158 
00159 TS_INLINE EThread *
00160 this_ethread()
00161 {
00162   return (EThread *) this_thread();
00163 }
00164 
00165 TS_INLINE void
00166 EThread::free_event(Event * e)
00167 {
00168   ink_assert(!e->in_the_priority_queue && !e->in_the_prot_queue);
00169   e->mutex = NULL;
00170   EVENT_FREE(e, eventAllocator, this);
00171 }
00172 
00173 #endif /*_EThread_h_*/

Generated by  doxygen 1.7.1