This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ev++.h> | |
#include <netinet/in.h> | |
#include <sys/socket.h> | |
#include <resolv.h> | |
#include <errno.h> | |
#include <list> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//list define | |
struct list_head { | |
struct list_head *next, *prev; | |
}; | |
#define LIST_HEAD_INIT(name) { &(name), &(name) } | |
//链表使用者定义: | |
struct user_t { | |
data domain; | |
struct list_head node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char *ping_pixels; | |
ping_pixels=(unsigned char *) NULL; | |
if (setjmp(png_jmpbuf(ping))) | |
{ | |
/* | |
PNG image is corrupt. | |
*/ | |
png_destroy_read_struct(&ping,&ping_info,&end_info); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef EVSERVER_HPP | |
#define EVSERVER_HPP | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ev++.h> | |
#include <netinet/in.h> | |
#include <sys/socket.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*++ | |
/* NAME | |
/* sock_addr 3 | |
/* SUMMARY | |
/* sockaddr utilities | |
/* SYNOPSIS | |
/* #include <sock_addr.h> | |
/* | |
/* int sock_addr_cmp_addr(sa, sb) | |
/* const struct sockaddr *sa; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <tuple> | |
#include <algorithm> | |
#include <type_traits> | |
template<class T> | |
using Invoke = typename T::type; | |
template<class T> | |
using Unqualified = Invoke<std::remove_cv<Invoke<std::remove_reference<T>>>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename ... MTArg> | |
struct Task { | |
typedef void (*RawFunction)(MTArg...); | |
//Here we want to forward some set of arguments into a tuple, but the arguments need not match MTArg -- they just have to be convertible: | |
template<typename ... Args> | |
explicit Task(RawFunction rawFunction, Args&&... args) | |
rawFunction(rawFunction), | |
args(std::make_tuple(std::forward<Args>(args)...)) {} | |
//which the above checks. Note I made it explicit, as if Args... is empty, we don't want this to be a converting constructor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This program is demo for using pthreads with libev. | |
//Try using Timeout values as large as 1.0 and as small as 0.000001 | |
//and notice the difference in the output | |
//(c) 2009 debuguo | |
//(c) 2013 enthusiasticgeek for stack overflow | |
//Free to distribute and improve the code. Leave credits intact | |
#include <ev.h> | |
#include <stdio.h> // for puts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
typedef unsigned int u32; | |
typedef unsigned long long u64; | |
//------------------------------------------------------------------------- | |
// WorkArea | |
//------------------------------------------------------------------------- |