You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2009/12/14 19:05:11 UTC

svn commit: r890418 - in /incubator/trafficserver/traffic/trunk/iocore/eventsystem: I_Event.h I_EventProcessor.h I_Lock.h P_UnixEThread.h P_UnixEventProcessor.h UnixEThread.cc

Author: jplevyak
Date: Mon Dec 14 18:05:10 2009
New Revision: 890418

URL: http://svn.apache.org/viewvc?rev=890418&view=rev
Log:
TS-82: remove/fix unimplemented event processor interfaces
remove the EventProcessor::schedule interfaces which take a thread argument 
which are not implemented, implement the callback_event which
for some reason was being ignored.  Also, add the operators to MutexLock
to match those of a MutexTryLock.

Modified:
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Event.h
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_EventProcessor.h
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Lock.h
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEThread.h
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEventProcessor.h
    incubator/trafficserver/traffic/trunk/iocore/eventsystem/UnixEThread.cc

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Event.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Event.h?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Event.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Event.h Mon Dec 14 18:05:10 2009
@@ -228,6 +228,7 @@
   unsigned int immediate:1;
   unsigned int globally_allocated:1;
   unsigned int in_heap:4;
+  int callback_event;
 
   ink_hrtime timeout_at;
   ink_hrtime period;
@@ -282,7 +283,6 @@
   virtual ~ Event() {
   }
 #endif
-
 };
 
 //

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_EventProcessor.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_EventProcessor.h?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_EventProcessor.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_EventProcessor.h Mon Dec 14 18:05:10 2009
@@ -116,26 +116,12 @@
   */
   EventType spawn_event_threads(int n_threads);
 
-  // not used
-  // Event *schedule_spawn(Continuation *cont);
-
+#if 0  
   /**
-    Schedules the continuation on a specific EThread to receive an event
-    as soon as possible.  Instructs the EventProcessor to schedule the
-    callback to the continuation 'c' as soon as possible. The event is
-    assigned to the specified EThread.
-
-    @param c Continuation to be called back as soon as possible.
-    @param ethread EThread on which to schedule the event.
-    @param callback_event code to be passed back to the continuation's
-      handler. See the Remarks section.
-    @param cookie user-defined value or pointer to be passed back in
-      the Event's object cookie field.
-    @return reference to an Event object representing the scheduling
-      of this callback.
-
+    Unused
   */
-  Event *schedule_imm(Continuation * c, Thread * ethread, int callback_event = EVENT_IMMEDIATE, void *cookie = NULL);
+  Event *schedule_spawn(Continuation *cont);
+#endif
 
   /**
     Schedules the continuation on a specific EThread to receive an event
@@ -155,68 +141,6 @@
       of this callback.
 
   */
-  Event *schedule_at(Continuation * c,
-                     ink_hrtime atimeout_at,
-                     Thread * ethread, int callback_event = EVENT_INTERVAL, void *cookie = NULL);
-
-  /**
-    Schedules the continuation on a specific EThread to receive an event
-    after the timeout elapses. Instructs the EventProcessor to schedule
-    the callback to the continuation 'c' after the time specified in
-    atimeout_in elapses.  The event is assigned to the specified EThread.
-
-    @param c Continuation to be called back after the timeout elapses.
-    @param atimeout_in amount of time after which to callback.
-    @param ethread EThread on which to schedule the event.
-    @param callback_event code to be passed back to the continuation's
-      handler. See the Remarks section.
-    @param cookie user-defined value or pointer to be passed back in
-      the Event's object cookie field.
-    @return reference to an Event object representing the scheduling
-      of this callback.
-
-  */
-  Event *schedule_in(Continuation * c,
-                     ink_hrtime atimeout_in,
-                     Thread * ethread, int callback_event = EVENT_INTERVAL, void *cookie = NULL);
-
-  /**
-    Schedules the continuation on a specific EThread to receive an
-    event periodically. Schedules the callback to the continuation 'c'
-    in the EventProcessor to occur every time 'aperiod' elapses. It is
-    scheduled on the specified EThread.
-
-    @param c Continuation to call back everytime 'aperiod' elapses.
-    @param aperiod duration of the time period between callbacks.
-    @param ethread EThread on which to schedule the event.
-    @param callback_event code to be passed back to the continuation's
-      handler. See the Remarks section.
-    @param cookie user-defined value or pointer to be passed back in
-      the Event's object cookie field.
-    @return reference to an Event object representing the scheduling of
-      this callback.
-
-  */
-  Event *schedule_every(Continuation * c,
-                        ink_hrtime aperiod, Thread * ethread, int callback_event = EVENT_INTERVAL, void *cookie = NULL);
-
-  /**
-    Schedules the continuation on a specific thread group to receive an
-    event as soon as possible. Instructs the EventProcessor to schedule
-    the callback to the continuation 'c' as soon as possible. The callback
-    is handled by a thread in the specified thread group (event_type).
-
-    @param c Continuation to be called back as soon as possible.
-    @param event_type thread group id (or event type) specifying the
-      group of threads on which to schedule the callback.
-    @param callback_event code to be passed back to the continuation's
-      handler. See the Remarks section.
-    @param cookie User-defined value or pointer to be passed back in
-      the Event's object cookie field.
-    @return reference to an Event object representing the scheduling of
-      this callback.
-
-  */
   Event *schedule_imm(Continuation * c,
                       EventType event_type = ET_CALL, int callback_event = EVENT_IMMEDIATE, void *cookie = NULL);
 

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Lock.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Lock.h?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Lock.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/I_Lock.h Mon Dec 14 18:05:10 2009
@@ -586,6 +586,15 @@
     if (m)
       Mutex_unlock(m, m->thread_holding);
   }
+
+  int operator!()
+  {
+    return false;
+  }
+  operator  bool()
+  {
+    return true;
+  }
 };
 
 struct MutexTryLock

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEThread.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEThread.h?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEThread.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEThread.h Mon Dec 14 18:05:10 2009
@@ -47,8 +47,8 @@
 INK_INLINE Event *
 EThread::schedule_imm(Continuation * cont, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e =::eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
 #ifdef ENABLE_TIME_TRACE
   e->start_time = ink_get_hrtime();
@@ -59,8 +59,8 @@
 INK_INLINE Event *
 EThread::schedule_at(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e =::eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, t, 0));
 }
@@ -68,8 +68,8 @@
 INK_INLINE Event *
 EThread::schedule_in(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e =::eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, ink_get_based_hrtime() + t, 0));
 }
@@ -77,8 +77,8 @@
 INK_INLINE Event *
 EThread::schedule_every(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e =::eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, ink_get_based_hrtime() + t, t));
 }
@@ -100,8 +100,8 @@
 INK_INLINE Event *
 EThread::schedule_imm_local(Continuation * cont, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = EVENT_ALLOC(eventAllocator, this);
+  e->callback_event = callback_event;
 #ifdef ENABLE_TIME_TRACE
   e->start_time = ink_get_hrtime();
 #endif
@@ -112,8 +112,8 @@
 INK_INLINE Event *
 EThread::schedule_at_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = EVENT_ALLOC(eventAllocator, this);
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule_local(e->init(cont, t, 0));
 }
@@ -121,8 +121,8 @@
 INK_INLINE Event *
 EThread::schedule_in_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = EVENT_ALLOC(eventAllocator, this);
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule_local(e->init(cont, ink_get_based_hrtime() + t, 0));
 }
@@ -130,8 +130,8 @@
 INK_INLINE Event *
 EThread::schedule_every_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = EVENT_ALLOC(eventAllocator, this);
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule_local(e->init(cont, ink_get_based_hrtime() + t, t));
 }

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEventProcessor.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEventProcessor.h?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEventProcessor.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/P_UnixEventProcessor.h Mon Dec 14 18:05:10 2009
@@ -94,11 +94,11 @@
 INK_INLINE Event *
 EventProcessor::schedule_imm(Continuation * cont, EventType et, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = eventAllocator.alloc();
 #ifdef ENABLE_TIME_TRACE
   e->start_time = ink_get_hrtime();
 #endif
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, 0, 0), et);
 }
@@ -106,9 +106,9 @@
 INK_INLINE Event *
 EventProcessor::schedule_at(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   ink_assert(t > 0);
   Event *e = eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, t, 0), et);
 }
@@ -116,8 +116,8 @@
 INK_INLINE Event *
 EventProcessor::schedule_in(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   Event *e = eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   return schedule(e->init(cont, ink_get_based_hrtime() + t, 0), et);
 }
@@ -125,9 +125,9 @@
 INK_INLINE Event *
 EventProcessor::schedule_every(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie)
 {
-  NOWARN_UNUSED(callback_event);
   ink_assert(t != 0);
   Event *e = eventAllocator.alloc();
+  e->callback_event = callback_event;
   e->cookie = cookie;
   if (t < 0)
     return schedule(e->init(cont, t, t), et);

Modified: incubator/trafficserver/traffic/trunk/iocore/eventsystem/UnixEThread.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/eventsystem/UnixEThread.cc?rev=890418&r1=890417&r2=890418&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/eventsystem/UnixEThread.cc (original)
+++ incubator/trafficserver/traffic/trunk/iocore/eventsystem/UnixEThread.cc Mon Dec 14 18:05:10 2009
@@ -165,7 +165,7 @@
         while ((e = EventQueueExternal.dequeue_local())) {
           if (!e->timeout_at) {
             ink_assert(e->period == 0);
-            process_event(e, EVENT_IMMEDIATE);
+            process_event(e, e->callback_event);
           } else {
 
             if (e->timeout_at < 0) {
@@ -199,7 +199,7 @@
               free_event(e);
             else {
               done_one = true;
-              process_event(e, e->immediate ? EVENT_IMMEDIATE : EVENT_INTERVAL);
+              process_event(e, e->callback_event);
             }
           }
         } while (done_one);
@@ -216,7 +216,7 @@
             EventQueueExternal.dequeue_timed(cur_time, next_time, false);
           while ((e = EventQueueExternal.dequeue_local())) {
             if (!e->timeout_at)
-              process_event(e, EVENT_IMMEDIATE);
+              process_event(e, e->callback_event);
             else {
               if (e->cancelled)
                 free_event(e);