RBL development Note 2

Source: Internet
Author: User

17:13:55 2014-08-25

There are several points:

First: How can we identify whether a macro is defined in the pre-processing stage? Here we define a systemconfig. h dedicated to this task. Of course, makefile is required to work together.

Http://blog.csdn.net/chaoqunz/article/details/6033663 this blog post has mentioned the corresponding method to add a-d parameter in makefile, which is equivalent to a complementary parameter in makefile.

  

  2nd: When I plan to write this RBL, I can use the configuration file to write three underlying modes:

A single process single thread Service Mode

B single-process multi-thread service mode [Normal lock]

C single-process multi-thread service mode [rw_lock lock]

No problem with 1st

For 2nd:

You need to develop the following things. 1) the configuration-like Security Section is like whether the Linux kernel is an SMP _ processing mode.

2)Single-threaded Service Mode: Using a redis-like service mode to solve this problem is to compare the epoll + single-process commands. This command will not take advantage of multiple cores, but will not exceed 100% of the CPU.

3)Multithreading Service Mode: Multi-thread + epoll this mode means that the epoll thread monitors Io events and immediately places them in the task queue. Other threads perform corresponding operations. This will take into account the type of the lock: whether to use the spin_lcok or mutex_lock. meticulous. [This point of view in programming technology is:Most difficult]

............ There are also several points that will be written slowly in subsequent development.

22:01:27 2014-08-25

Today's progress is a little slow. I simply wrapped a socket. h eventloop. h, but now I am wondering how to better encapsulate eventloop and epoll and encapsulate Io read/write operations. 【**]

Tomorrow's development task: 1. Embed epoll into the eventloop class and write the corresponding test program.

2. Read and Write the bloomfilter and perform unit tests.

      

 

# Ifndef _ socket _ # DEFINE _ socket _ # include <sys/types. h> # include <sys/socket. h> # include <netinet/in. h> # include <string> # include <ARPA/inet. h> // TCP Service class socket {public: socket (int serverport) {soketfd = socket (af_inet, sock_stream, 0); seraddr. sin_family = af_inet; seraddr. sin_addr.s_addr = htonl (inaddr_any); seraddr. sin_port = htons (SERVERPORT);} int getfd () {return soketfd;} struct sockaddr_in * getseraddr () {return & seraddr;} PRIVATE: int soketfd; struct sockaddr_in seraddr ;}; // The client creates class clientconnection {public: clientconnection (INT port, const STD: string & IP _): sock (port), IP (IP _) {inet_ton (af_inet, IP. c_str (), & sock. getseraddr ()-> sin_addr);} void connect (void) {connect (sock. getfd (), (struct sockaddr *) sock. getseraddr (), sizeof (struct sockaddr);} PRIVATE: Socket sock; STD: String IP ;}; // create a class serverconnection {public: serverconnection (INT port) on the server): sock (port) {BIND (sock. getfd (), (struct sockaddr *) sock. getseraddr (), sizeof (struct sockaddr_in); // The Listener queue temporarily defines a value of 8 listen (sock. getfd (), 8);} socket & getsock () {return sock;} PRIVATE: Socket sock;}; # endif

 

  

 

 

 

  

RBL development Note 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.