- 浏览: 48735 次
- 来自: ...
最新评论
文章列表
#include <stdio.h>#include "AuthenHandle.h"#include "configure.h"#ifdef WIN32 //for windows nt/2000/xp
#include <winsock.h>#include <windows.h>#include "gelsserver.h"#pragma comment(lib,"Ws2_32.lib")#else //for unix
#include <sys/ ...
#iostream#fsteamifstream in;ofstream out;in.open(SourceFile,ios::binary);if(in.fail()){ in.close(); out.close(); return 0;}out.open(NewFile,ios::binary);if(out.fail()){ out.close(); in.close(); return 0;}else{ out<<in.rdbuf(); out.close(); in.close();}
表类型
MySQL的数据表类型很多,其中比较重要的是MyISAM,InnoDB这两种。
这两种类型各有优缺点,需要根据实际情况选择适合的,MySQL支持对不同的表设置不同的类型。下面做个对比:
MyISAM表类型是一种比较成熟稳定的表类型,但是MyISAM对一些功能不支持。
MyISAM
InnoDB
事务
不支持
支持
数据行锁定
不支持,只有表锁定
支持
外键约束
不支持
支持
表空间大小
相对小
相对大,最大是2倍
全文索引
支持
不支持
GIS数据
支持
不支 ...
#include<sys\stat.h>
char* filepath = ".\\test.db3"; struct _stat info; _stat(filepath, &info); int size = info.st_size; cout<<size<<endl;
#include <boost/bind.hpp>#include <iostream> #include <string>#include <windows.h>using namespace std;
template <class T>AsynchQueue<T>::AsynchQueue() { hMutex = CreateMutex(NULL, FALSE, NULL); hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);}
template <class T ...
/*boost::function<void()> f; f = boost::bind(threadfunc); FuncThread thread(f);*/ //thread.run();
boost::function<void()> f; f = boost::bind(threadfunc); f();
/*boost::thread thrd(f);*/
/*WorkPool wp; wp.start(); wp.post(thread);*/
#include "StdAfx.h"#include "W ...
背景
• 今天互联网应用服务程序普遍使用多线程来提高与多客户链接时的效率;为了达到最大的吞吐量,事务服务器在单独的线程上运行服务程序;
GUI应用程序将那些费时,复杂的处理以线程的形式单独运行,以此来保证用户界面能够及时响应用户的操作。这样使用多线程的例子还有很多。
• 跨平台
创建线程
• 头文件 <boost/thread/thread.hpp>
namespace boost {
class thread;
class thread_group;
}
• thread(): ...
一个简单的线程池模型实现
1人收藏此文章, 我要收藏 发表于3个月前(2012-06-13 21:47) , 已有145次阅读 共1个评论
1. 简介
在EPoll通信模型中,我们常常使用如下的处理方法:
就是将触发的事件交给线程去做而EPoll只管接收产生 ...
封装
4人收藏此文章, 我要收藏 发表于3个月前(2012-06-11 23:08) , 已有313次阅读 共6个评论
最近在看陈硕的MUDUO网络通信库的过程中,发现作者大量使用了Boost::function以及Boost::bind功能,为了能够正常的学习作者的代码,决定先弄明白function以及bind的功能。
Boost::Function 是对函数指针的对象化封装,在概念上与广义上的回调函数类似。相对于函数指针,function除了使用自由函数,还可以使用函数对象,甚至是类的成员函数,这个就很强大了哈。
1. 一个简单的示例代码
v ...
ptree p1,p2,p3; p1 = pt.get_child("deviece");//访问多级节点中的数组数据
p2 = p1.begin()->second.begin()->second.begin()->second; string id_str = p2.get<string>("id"); p3 = p2.get_child("dataItems").begin()->second.get_child("20000001").begin()-& ...
393739858
TiXmlDocument *pDoc = new TiXmlDocument(); pDoc->LoadFile("config.xml"); TiXmlElement *root = pDoc->RootElement(); cout<< root->Value()<<endl;
__int64 t1, t2, tc; QueryPerformanceCounter((LARGE_INTEGER *)&t1);
for(int i=0;i<100;i++) { TiXmlNode ...
1.向线程PostMessage 函数controlled_module_ex::postmessage完成消息推送。 虚拟函数controlled_module_ex::message(const _command & cmd)实现消息接收。
#include "controlled_module_ex.hpp"
class thdex: public controlled_module_ex
{
protected:
virtual void message(const _command & cmd)
{
...
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
#include "controlled_module.hpp"
struct _command
{
typedef boost::shared_ptr<_command> CCmdPtr;
unsigned int nCmd;
boost::any anyParam;
};
struct _wait_command
{ ...
boost有两种使用方式,一种是编译成库进行使用,另外一种在工程中直接引入源码。
boost编译:
a.编译jam
1.下载最新版版的boost压缩包(1.47.0),解压保存(ex:d:\boost)
2.运行vs命令行提示符。
3.执行命令cd d:\boost\tools\build\v2\engine(其他的版本可能位于d:\boost\
tools\jam\src)
4.运行build.bat编译jam,编译生成的bjam.exe位于当前目录下的bin.ntx86目录下,要将它复制到boost的根目录。
b.配置
三年来一直从事服务器程序开发,一直都是忙忙碌碌,不久前结束了职业生涯的第一份工作,有了一个礼拜的休息时间,终于可以写写总结了。于是把以前的开源代码做了整理和优化,这就是FFLIB。虽然这边总结看起来像日记, ...