随笔分类 - C++
摘要:变量定义的基本形式: 首先是类型说明符,随后紧跟由一个或多个变量名组成的列表,其中变量名以逗号分割,最后以分号结束。(摘自《C++ Primer 第5版 2.2.1》) 变量声明: 一条声明语句由一个基本数据类型和紧随气候的一个声明符列表组成。(摘自《C++ Primer 第5版 2.3》) 声明和
阅读全文
摘要:struct event_config *event_config_new(void); /** Allocates a new event configuration object. 分配一个新的event_config对象 The event configuration object can b
阅读全文
摘要:原型 void lock(); 锁住互斥量 调用的线程会锁住互斥量(mutex),必要的话会被阻塞: 如果其它任何线程没有对互斥量进行锁操作,调用线程会对互斥量进行锁操作(从这一时刻开始,直到调用unlock,互斥量为调用线程拥有) 如果其它线程又锁住互斥量,再次执行lock的线程会被阻塞,直到拥有
阅读全文
摘要:客户端 #pragma once #include <event2/util.h> class libevent_client { public: libevent_client(); ~libevent_client(); void initial(int port); void connect_
阅读全文
摘要:客户端 #pragma once #include <event2/util.h> class libevent_client { public: libevent_client(); ~libevent_client(); void initial(int port); void connect_
阅读全文
摘要:接口:event_base_dispatch /** Event dispatching loop 事件分配循环 This loop will run the event base until either there are no more pending or active, or until
阅读全文
摘要:read,读取数据 /** Read data from a bufferevent buffer. The bufferevent_read() function is used to read data from the input buffer.从输入缓存中读取数据 @param bufev
阅读全文
摘要:/** Allocate and asssign a new event structure, ready to be added. 分配并指定一个新的event结构体,这个结构体将被添加。 The function event_new() returns a new event that can
阅读全文
摘要:/** Launch a connect() attempt with a socket-based bufferevent. 使用一个socket-based bufferevent来启动connect() When the connect succeeds, the eventcb will b
阅读全文
摘要:/** Changes the callbacks for a bufferevent.通过回调函数来改变bufferevent @param bufev the bufferevent object for which to change callbacks回调函数将要改变的bufferevent
阅读全文
摘要:operator new 通过C++的网站,可以知道operator new,有三种形式。这里只对第一种进行说明 分配存储空间:默认的分配函数 throwing allocation 分配size存储字节,合适的对齐,用来表示位于那块内存的任何对象,并返回一个指向这块内存的非空指针。 如果失败,会抛
阅读全文
摘要:.h #pragma once #include <iostream> class operate_array { public: operate_array(int size); operate_array(int size, int value); ~operate_array(); priva
阅读全文
摘要:.h #pragma once #include "operate_array.h" class operate_queue { public: operate_queue(int capacity, int value); ~operate_queue(); void in_queue(int e
阅读全文
摘要:头文件 #pragma once #include <iostream> class operate_array { public: operate_array(int size); ~operate_array(); private: int *m_pArray; int m_isize; int
阅读全文
摘要:在tcp通信中,会用到event_base这个结构体。 下面来看看这个结构体。 event_base_new(),创建event_base /** * Create and return a new event_base to use with the rest of Libevent. * 创建并
阅读全文
摘要:1.说明 程序是个简单的服务端程序,用于监听9995端口上的tcp连接。当有客户端接入,服务端会向客户端发送一条消息。 2.主线程代码解析 // 创建关于libevent变量 struct event_base *base; struct evconnlistener *listener; stru
阅读全文
摘要:通过typedef自定义的类型,放在私有中,在公有中使用,提示未定义。 将typedef unsigned char uchar;定义为私有的的声明放在接口声明的前面
阅读全文
摘要:通过VS,使用向导生成C++类。如下: 通过上面的代码段,可以看到VS为我们自动添加了显示定义的构造函数和析构函数。如上的这种构造函数和析构函数,也被称为缺省的构造函数和缺省的析构函数。 如上代码段,将VS添加的显示定义的构造函数和析构函数代码给删除。这依然是一个正常的类。C++编译器会添加默认的构
阅读全文
摘要:最近看了下c++11的线程。看了不少博客,这里会引用到CSDN里Nine-days博客里的demo。 notify_one:唤醒等待线程中的一个。 notify_all:唤醒所有等待的线程。 wait:等待。需要其它的接口来唤醒。 通过main函数,知道实例化了3个线程。线程A,B,C在创建后被阻塞
阅读全文

浙公网安备 33010602011771号