p9y
[awesomized/libmemcached] / src / libmemcached / hash.cc
index 33766b5fd50420bc0941a41e3d5de5065b8edba2..3e147f8797e07106645e95134d0a0d0a302a467c 100644 (file)
 */
 
 #include "libmemcached/common.h"
-
-#include <sys/time.h>
-
 #include "libmemcached/virtual_bucket.h"
+#include "p9y/gettimeofday.hpp"
+#include "p9y/random.hpp"
 
 uint32_t memcached_generate_hash_value(const char *key, size_t key_length,
                                        memcached_hash_t hash_algorithm) {
@@ -52,8 +51,10 @@ static uint32_t dispatch_host(const Memcached *ptr, uint32_t hash) {
       right = begin;
     return right->index;
   }
-  case MEMCACHED_DISTRIBUTION_MODULA: return hash % memcached_server_count(ptr);
-  case MEMCACHED_DISTRIBUTION_RANDOM: return (uint32_t) random() % memcached_server_count(ptr);
+  case MEMCACHED_DISTRIBUTION_MODULA:
+    return hash % memcached_server_count(ptr);
+  case MEMCACHED_DISTRIBUTION_RANDOM:
+    return (uint32_t) random() % memcached_server_count(ptr);
   case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: {
     return memcached_virtual_bucket_get(ptr, hash);
   }