上一页 1 2 3 4 5 6 7 8 ··· 17 下一页
摘要: 之前没有接触过数据库编程,尼玛,面试神码的最恶心了,非得神码都懂点,好吧,最近开始研究下,先从SQLite开始吧,贴上找到SQliteDB。之后搜集资料,慢慢学习! 阅读全文
posted @ 2013-08-19 12:55 hailong 阅读(284) 评论(0) 推荐(0)
摘要: 大家自己分析吧#pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIM... 阅读全文
posted @ 2013-08-18 22:09 hailong 阅读(1035) 评论(0) 推荐(0)
摘要: #pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIMAGE min... 阅读全文
posted @ 2013-08-18 19:08 hailong 阅读(1164) 评论(0) 推荐(0)
摘要: #pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIMAGE min... 阅读全文
posted @ 2013-08-18 18:40 hailong 阅读(524) 评论(0) 推荐(0)
摘要: typedef struct min_heap{ struct event** p; unsigned n, a;} min_heap_t;static inline void min_heap_ctor_(min_heap_t* s);static inline void min_heap_dtor_(min_heap_t* s);static inline void min_heap_elem_init_(struct event* e);static inline int min_heap_elt_is_top_... 阅读全文
posted @ 2013-08-12 23:10 hailong 阅读(1640) 评论(0) 推荐(0)
摘要: 从msdn上看二者的解释:postmessage :Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.To post a message in the message queue associated with a thread, use thePostThreadMessagefunction.The 阅读全文
posted @ 2013-08-12 17:25 hailong 阅读(378) 评论(0) 推荐(0)
摘要: 摘自stackflow的回答,主要从架构上说明了二者的区别:As for design philosophy, libev was created to improve on some of the architectural decisions in libevent, for example, global variable usage made it hard to use libevent safely in multithreaded environments, watcher structures are big because they combine I/O, time and 阅读全文
posted @ 2013-08-11 20:50 hailong 阅读(1473) 评论(0) 推荐(1)
摘要: 好吧,神马都init好了,loop毕竟是个环呐,在哪跑起来呢,ok,他是ev_run的工作:int ev_run (EV_P_ int flags){#if EV_FEATURE_API ++loop_depth;#endif assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE)); loop_done = EVBREAK_CANCEL; EV_INVOKE_PENDING; /* in case we recurse, ensure orderi 阅读全文
posted @ 2013-08-10 20:30 hailong 阅读(7267) 评论(0) 推荐(0)
摘要: #define ev_io_init(ev,cb,fd,events) / do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)/看到没,这就是C语言的恶心指出,尼玛找个定一点都要用全局搜索字符,才找到这个宏。好吧,看它都做了写神马东东:ev_init ((ev), (cb));就是把watcher进行初始化,把回调设置进去;ev是神马玩意呢,就是ev_io:/* invoked when fd is either EV_READable or EV_WRITEable *//* reven... 阅读全文
posted @ 2013-08-10 17:36 hailong 阅读(9302) 评论(1) 推荐(1)
摘要: /* these may evaluate ev multiple times, and the other arguments at most once *//* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */#define ev_init(ev,cb_) do { \ ((ev_watcher *)(void *)(ev))->active = \ ((ev_watcher *)(void *)(ev))... 阅读全文
posted @ 2013-08-10 15:34 hailong 阅读(2116) 评论(0) 推荐(0)
摘要: 尼玛 C语言学不好真是桑心呐!看了libev的代码有一种想死的感觉,但是还是要硬着头皮看下去,一定看完!/* initialise a loop structure, must be zero-initialised */static void loop_init ( unsigned int flags){ if (!loop->backend) { origflags = flags;#if EV_USE_REALTIME if (!have_realtime) { struct timespec ts; if ... 阅读全文
posted @ 2013-08-10 15:07 hailong 阅读(2411) 评论(0) 推荐(0)
摘要: libev作为优秀的高性能IO框架,非常值得学习!虽然我是菜鸟,但也必须学习啦,从今天一点一点地学习,慢慢进步!# include "ev.h"struct event_base;//定义事件类型码,注意啦,都是2的指数幂#define EVLIST_TIMEOUT 0x01#define EVLIST_INSERTED 0x02#define EVLIST_SIGNAL 0x04#define EVLIST_ACTIVE 0x08#define EVLIST_INTERNAL 0x10#define EVLIST_INIT 0x80//定义回调函数typedef void 阅读全文
posted @ 2013-08-10 13:02 hailong 阅读(1921) 评论(0) 推荐(0)
摘要: 转自:酷壳http://coolshell.cn/articles/8990.html感谢网友full_of_bull投递此文(注:此文最初发表在这个这里,我对原文后半段修改了许多,并加入了插图)Linus大婶在slashdot上回答一些编程爱好者的提问,其中一个人问他什么样的代码是他所喜好的,大婶表述了自己一些观点之后,举了一个指针的例子,解释了什么才是core low-level coding。下面是Linus的教学原文及翻译——“At the opposite end of the spectrum, I actually wish more people understood the 阅读全文
posted @ 2013-07-07 22:33 hailong 阅读(297) 评论(0) 推荐(0)
摘要: 在网上找了个例子,其实libevent本身带了很多测试用例,不过这是第一次编译成功,尼玛 各种高性能IO库都是在linux下的,win32果断被bs了,还好有libevent对win32支持的比较好。lib很顺利的编译好了。下面就是很简单的使用下socket:#include #include #include #include #include #include #include #pragma comment(lib,"ws2_32.lib")#include #include #define LISTEN_PORT 9999#define LISTEN_BACKLOG 阅读全文
posted @ 2013-07-04 10:01 hailong 阅读(3183) 评论(0) 推荐(0)
摘要: 之前看到 偶尔用placement new 的用法,当分配内存频繁,而且对效率要求很高的情况下,可以先申请一块大内存,然后在此内存上构建对象,关键是可以自动调用其构造函数,否则要悲剧。但是之后要自己显式调用其析构函数,因为编译器也认为这是你new出来的,不会帮你调用,当然类在析构的时候做了两件事,调用析构函数,然后把内存还给os,对于placement new同样也需要这么做,但是要自己做: 1 #include 2 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 class A10 {11 public... 阅读全文
posted @ 2013-06-30 06:31 hailong 阅读(212) 评论(0) 推荐(0)
摘要: #pragma once#include <QTableView>#include <QStandardItemModel>#include <QTableWidget>#include <QtGui>#include <QDrag>class DragTabel : public QTableView{public: DragTabel(QWidget *parent = 0); void AddItem(QString aName);protected: void mousePressEvent(QMouseEvent *even 阅读全文
posted @ 2013-06-05 10:34 hailong 阅读(4104) 评论(0) 推荐(0)
摘要: Wait functionsallow a thread to block its own execution. The wait functions do not return until the specified criteria have been met. The type of wait function determines the set of criteria used. When a wait function is called, it checks whether the wait criteria have been met. If the criteria have 阅读全文
posted @ 2013-05-19 09:30 hailong 阅读(398) 评论(0) 推荐(0)
摘要: 最近开始学习Java,java编程思想的确是本好书。现在看到第二章了,按照示例代码敲出来:import java.util.*;public class Example { public static void main(String[] args) { System.out.println (new Date()); System.out.println("Memeory"); Runtime rt = Runtime.getRuntime(); System.out.println("Tot Memory: " + rt.totalMemory() 阅读全文
posted @ 2013-05-16 21:39 hailong 阅读(171) 评论(0) 推荐(0)
摘要: Asynchronous I/O, ornon-blocking I/O, in computer science, is a form ofinput/outputprocessing that permits other processing to continue before thetransmissionhas finished.Input and output (I/O) operations on a computer can be extremely slow compared to the processing of data. An I/O device can incor 阅读全文
posted @ 2013-03-30 18:32 hailong 阅读(352) 评论(0) 推荐(0)
摘要: 原来代码:#include <boost/thread.hpp>#include <iostream>class Base{public: virtual void Do() = 0;};class Derived1: public Base{public: virtual void Do() { std::cout << "Derived1:Do\n"; }};class Derived2: public Base{public: virtual void Do() { std::cout << "Derived1 阅读全文
posted @ 2013-03-03 10:30 hailong 阅读(971) 评论(0) 推荐(0)
摘要: A quick note about usages of fields. My experience is that many who implement FIX do it slightly differently. So be aware that though I am trying to explain correct usage you may find that there are differences between implementations. When I connect to a new broker I get a FIX specification which d 阅读全文
posted @ 2013-02-26 22:15 hailong 阅读(506) 评论(0) 推荐(0)
摘要: YourfromApp()callback gets aMessageobject. That message is actually a NewOrderSingle or ExecutionReport or something. Rather than making you figure it out, QF lets you inherit fromMessageCracker. To use it, callcrack()in yourfromApp(), as follows:void fromApp( const FIX::Message& message, const 阅读全文
posted @ 2013-02-26 22:03 hailong 阅读(537) 评论(0) 推荐(0)
摘要: 在消息中添加自定义字段有两个步骤。例如,我们将增加TAG(9006)的AwesomeField字符串字段。首先,把它添加数据字典的Fields当中:<fields><fieldnumber="1"name="Account"type="STRING"/><fieldnumber="2"name="AdvId"type="STRING"/><fieldnumber="3"name="AdvRefID&quo 阅读全文
posted @ 2013-02-26 11:26 hailong 阅读(1209) 评论(1) 推荐(0)
摘要: We are looking for Senior Windows C++ developers with strong network programming experience. The senior developer will focus on specifying, designing, prototyping and implementing the industry-leading SaaS-based datacenter monitoring solution for Windows platformQualifications:BS/MS degree and 3+ ye 阅读全文
posted @ 2013-02-24 14:38 hailong 阅读(197) 评论(0) 推荐(0)
摘要: 贴下来学习,转自http://www.cnblogs.com/zhiranok/archive/2012/05/13/cpp_multi_thread.html#ifndef _TASK_QUEUE_IMPL_H_#define _TASK_QUEUE_IMPL_H_#include<pthread.h>#include <list>#include <stdexcept>using namespace std;#include "task_queue_i.h"#include "lock.h"namespace ff 阅读全文
posted @ 2013-01-28 07:34 hailong 阅读(379) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2013-01-21 21:02 hailong 阅读(3) 评论(0) 推荐(0)
摘要: From:真 OO无双http://www.cnblogs.com/oomusou/archive/2007/05/02/734290.htmlAbstractFunction Pointer(C)、Delegate(C#)和Function Object(C++)這三個其實是一樣的功能,所以在此一併討論。Introductionfunction pointer是C語言中最高級的機制,大概很多人還沒上到這裡已經學期末了,所以不少C語言工程師根本不知道C語言有function pointer;而C#的delegate大抵跟C語言的function pointer功能相同,所以很多書說delega 阅读全文
posted @ 2013-01-12 21:52 hailong 阅读(406) 评论(0) 推荐(0)
摘要: http://www.wuzesheng.com/?p=1258本文的主要内容是google protobuf中序列化数据时用到的编码规则,但是,介绍具体的编码规则之前,我觉得有必要先简单介绍一下google protobuf。因此,本文首先会介绍一些google protobuf相关的内容,让读者朋友对google protobuf有一个初步的印象,然后,再开始进入正题—-深入浅出地介绍google protobuf中用到的编码规则。下面言归正传,开始今天的话题。1. Google-ProtoBuf是什么ProtoBuf,全称是Protocol Buffers, 它是谷歌内部用的一种高效的、 阅读全文
posted @ 2012-12-31 17:40 hailong 阅读(1474) 评论(0) 推荐(0)
摘要: From:http://hi.baidu.com/mryuan0/item/62876af79667c6d76325d2f21. 对于用户传递过来的数据,通过转换以其他格式存储,move消耗的时间并不多,关键要设计一个好的内存分配器,比如说memtable的设计。2.所有类的数据成员以_结束3.序列化,数据格式统一little endian, 测试代码可以这样做, 其中网络字节序列是big endian,而很多机器是little endian, 因为google采用变长整数编码,它就只能使用little endian,这和编码过程密切相关的。陈硕在其muduo中使用的endian.h头文件的函 阅读全文
posted @ 2012-12-31 15:59 hailong 阅读(497) 评论(0) 推荐(0)
摘要: 昨天同事问到:单例模式和全局变量有何区别?全局变量可以创建多个实例,但单例模式只能创建一个(每次得调用GetInstance()之类的唯一方法得到);而全局变量的class,你可以在任何包含它的地方实例化对象,A a,A b; and so on;但对于单例模式,无论在哪:A a =GetInstance(), A b =GetInstance();除此之外,更无他法,因此单例模式自己负责创建唯一实例;你绝不可能创建 A a;因为它的构造函数是private的。另外全局的话,就只有一般性,木有什么变化了;在想要的地方给予一定的参数来得到这个唯一对象,应该才是满足需要的。当然全局对象无论用到与否 阅读全文
posted @ 2012-11-03 08:33 hailong 阅读(7904) 评论(0) 推荐(1)
上一页 1 2 3 4 5 6 7 8 ··· 17 下一页