X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fbin%2Fmemaslap%2Fms_thread.h;h=6ae1bb7bcbdea5dfb681fbd7d8a41ca5cf01b622;hb=7c2da91b9897c54f66e7fc634a675fcaeef32167;hp=8cb98bde97461c6ceb9b6d32668e0df5b5463516;hpb=f48bae7d4b6a832b0d3a71812125770f09c76239;p=awesomized%2Flibmemcached diff --git a/src/bin/memaslap/ms_thread.h b/src/bin/memaslap/ms_thread.h index 8cb98bde..6ae1bb7b 100644 --- a/src/bin/memaslap/ms_thread.h +++ b/src/bin/memaslap/ms_thread.h @@ -1,29 +1,18 @@ /* - * File: ms_thread.h - * Author: Mingqiang Zhuang - * - * Created on February 10, 2009 - * - * (c) Copyright 2009, Schooner Information Technology, Inc. - * http://www.schoonerinfotech.com/ - * - */ + +--------------------------------------------------------------------+ + | libmemcached - C/C++ Client Library for memcached | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted under the terms of the BSD license. | + | You should have received a copy of the license in a bundled file | + | named LICENSE; in case you did not receive a copy you can review | + | the terms online at: https://opensource.org/licenses/BSD-3-Clause | + +--------------------------------------------------------------------+ + | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | + | Copyright (c) 2020 Michael Wallner | + +--------------------------------------------------------------------+ +*/ -/** - * Asynchronous memslap has the similar implementation of - * multi-threads with memcached. Asynchronous memslap creates - * one or more self-governed threads; each thread is bound with - * one CPU core if the system supports setting CPU core - * affinity. And every thread has private variables. There is - * less communication or some shared resources among all the - * threads. It can improve the performance because there are - * fewer locks and competition. In addition, each thread has a - * libevent to manage the events of network. Each thread has one - * or more self-governed concurrencies; each concurrency has one - * or more socket connections. All the concurrencies don't - * communicate with each other even though they are in the same - * thread. - */ #ifndef MS_THREAD_H #define MS_THREAD_H @@ -35,42 +24,38 @@ extern "C" { #endif /** Time relative to server start. Smaller than time_t on 64-bit systems. */ -typedef unsigned int rel_time_t; +typedef unsigned int rel_time_t; /* Used to store the context of each thread */ -typedef struct thread_ctx -{ - uint32_t thd_idx; /* the thread index */ - uint32_t nconns; /* how many connections included by the thread */ - uint32_t srv_idx; /* index of the thread */ - int tps_perconn; /* expected throughput per connection */ - int64_t exec_num_perconn; /* execute number per connection */ +typedef struct thread_ctx { + uint32_t thd_idx; /* the thread index */ + uint32_t nconns; /* how many connections included by the thread */ + uint32_t srv_idx; /* index of the thread */ + int tps_perconn; /* expected throughput per connection */ + int64_t exec_num_perconn; /* execute number per connection */ } ms_thread_ctx_t; /* Used to store the private variables of each thread */ -typedef struct thread -{ - ms_conn_t *conn; /* conn array to store all the conn in the thread */ - uint32_t nactive_conn; /* how many connects are active */ +typedef struct thread { + ms_conn_t *conn; /* conn array to store all the conn in the thread */ + uint32_t nactive_conn; /* how many connects are active */ - ms_thread_ctx_t *thread_ctx; /* thread context from the caller */ - struct event_base *base; /* libevent handler created by this thread */ + ms_thread_ctx_t *thread_ctx; /* thread context from the caller */ + struct event_base *base; /* libevent handler created by this thread */ - rel_time_t curr_time; /* current time */ - struct event clock_event; /* clock event to time each one second */ - bool initialized; /* whether clock_event has been initialized */ + rel_time_t curr_time; /* current time */ + struct event clock_event; /* clock event to time each one second */ + bool initialized; /* whether clock_event has been initialized */ - struct timeval startup_time; /* start time of the thread */ + struct timeval startup_time; /* start time of the thread */ } ms_thread_t; /* initialize threads */ void ms_thread_init(void); - /* cleanup some resource of threads when all the threads exit */ void ms_thread_cleanup(void); - #ifdef __cplusplus } #endif