xutils.h 1.1 KB
Newer Older
W
wangguibao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
/***************************************************************************
 * 
 * Copyright (c) 2008 Baidu.com, Inc. All Rights Reserved
 * $Id: xutils.h,v 1.1 2008/09/03 06:47:49 xiaowei Exp $ 
 * 
 **************************************************************************/
 
 
 
/**
 * @file xutils.h
 * @author xiaowei(com@baidu.com)
 * @date 2008/06/12 23:45:24
 * @version $Revision: 1.1 $ 
 * @brief 
 *  
 **/


#ifndef  __XUTILS_H_
#define  __XUTILS_H_
#include <pthread.h>
#include <sys/time.h>

#define XTIMEDIFF(s, e) ((e.tv_sec-s.tv_sec)*1000+(e.tv_usec-s.tv_usec)/1000)


typedef void * thread_fun_t(void *);
struct xthread_t
{
	thread_fun_t * fun;
	void * param;
	int pnum;
};

int run_thread(void *(*fun)(void *), void *, int);
int run_thread(xthread_t *ptr, int size);

class Slotime
{
public:
	pthread_mutex_t lock;
	pthread_cond_t cond;
	timeval _s, _e;
	int pnum;
	int inp;
public:
	Slotime(int tpnum);
	~Slotime();
	int cost();
	int start();
	int stop();
};

void xrecord(const char *fn, const char *fmt, ...);








#endif  //__XUTILS_H_

/* vim: set ts=4 sw=4 sts=4 tw=100 */