You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2019/01/09 16:59:14 UTC

[trafficserver] branch master updated: Cleanup: Make _next_round_robin uint64_t

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ad1270  Cleanup: Make _next_round_robin uint64_t
1ad1270 is described below

commit 1ad12700c2750774cf98bc3c83ff5aea6f83a79c
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Tue Jan 8 09:07:43 2019 +0900

    Cleanup: Make _next_round_robin uint64_t
---
 iocore/eventsystem/I_EventProcessor.h     | 6 +++---
 iocore/eventsystem/P_UnixEventProcessor.h | 7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/iocore/eventsystem/I_EventProcessor.h b/iocore/eventsystem/I_EventProcessor.h
index 3730b49..2bf9010 100644
--- a/iocore/eventsystem/I_EventProcessor.h
+++ b/iocore/eventsystem/I_EventProcessor.h
@@ -303,9 +303,9 @@ public:
   /// The thread group ID is the index into an array of these and so is not stored explicitly.
   struct ThreadGroupDescriptor {
     std::string _name;                               ///< Name for the thread group.
-    int _count                = 0;                   ///< # of threads of this type.
-    std::atomic<int> _started = 0;                   ///< # of started threads of this type.
-    int _next_round_robin     = 0;                   ///< Index of thread to use for events assigned to this group.
+    int _count                 = 0;                  ///< # of threads of this type.
+    std::atomic<int> _started  = 0;                  ///< # of started threads of this type.
+    uint64_t _next_round_robin = 0;                  ///< Index of thread to use for events assigned to this group.
     Que(Event, link) _spawnQueue;                    ///< Events to dispatch when thread is spawned.
     EThread *_thread[MAX_THREADS_IN_EACH_TYPE] = {}; ///< The actual threads in this group.
     std::function<void()> _afterStartCallback  = nullptr;
diff --git a/iocore/eventsystem/P_UnixEventProcessor.h b/iocore/eventsystem/P_UnixEventProcessor.h
index ba58de9..ed97729 100644
--- a/iocore/eventsystem/P_UnixEventProcessor.h
+++ b/iocore/eventsystem/P_UnixEventProcessor.h
@@ -54,12 +54,7 @@ EventProcessor::assign_thread(EventType etype)
 
   ink_assert(etype < MAX_EVENT_TYPES);
   if (tg->_count > 1) {
-    // When "_next_round_robin" grows big enough, it becomes a negative number,
-    // meaning "next" is also negative. And since "next" is used as an index
-    // into array "_thread", the result is returning NULL when assigning threads.
-    // So we need to cast "_next_round_robin" to unsigned int so the result stays
-    // positive.
-    next = static_cast<unsigned int>(++tg->_next_round_robin) % tg->_count;
+    next = ++tg->_next_round_robin % tg->_count;
   } else {
     next = 0;
   }