上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 29 下一页
摘要: 原文:http://www.myexception.cn/program/681578.htmlPoco::ThreadPoco实现线程的机制,它将线程Thread和线程运行的实体Runnable分离开来,就像一个框架,Thread管理线程优先级,堆栈,维护线程局部变量;而运行的代码是在Runnable的子类run方法中实现的。我们在MyRunnable中,重写run方法,实现线程逻辑代码,然后调用Thread中的start方法启动线程,用join回收线程资源。静态方法sleep用于延时挺有用的。如果我们想将一个静态方法或全局函数用做线程的代码,可以使用ThreadTarget对那个函数进行包 阅读全文
posted @ 2013-02-20 13:07 Leo Forest 阅读(1157) 评论(1) 推荐(1) 编辑
摘要: 原文:http://blog.hiwgy.com/2011/06/02/pthread_cond_timedwait/摘要:多线程编程中,线程A循环计算,然后sleep一会接着计算(目的是减少CPU利用率);存在的问题是,如果要关闭程序,通常选择join线程A等待线程A退出,可是我们必须等到sleep函数返回,该线程A才能正常退出,这无疑减慢了程序退出的速度。当然,你可以terminate线程A,但这样做很不优雅,且会存在一些未知问题。采用pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t *mutex, const st 阅读全文
posted @ 2013-02-19 22:10 Leo Forest 阅读(560) 评论(0) 推荐(0) 编辑
摘要: procon.cc#include <cstdlib>#include <iostream>#include <vector>#include <Poco/Thread.h>#include <Poco/Runnable.h>#include <Poco/Mutex.h>using Poco::Runnable;using Poco::Thread;using Poco::Mutex;using Poco::FastMutex;class SharedResourc { public: void produce() { _ 阅读全文
posted @ 2013-02-18 18:34 Leo Forest 阅读(529) 评论(0) 推荐(0) 编辑
摘要: timer.cc#include <cstdlib>#include <iostream>#include <Poco/Timer.h>#include <Poco/Thread.h>using Poco::Timer;using Poco::TimerCallback;using Poco::Thread;class TimerExample{ public: void onTimer(Timer& timer) { std::cout << "onTimer called." << std: 阅读全文
posted @ 2013-02-18 10:37 Leo Forest 阅读(1837) 评论(0) 推荐(0) 编辑
摘要: 原文:LARGE_INTEGER类型 和 QueryPerformanceFrequency()LARGE_INTEGERLARGE_INTEGER是union;用于表示一64位有符号整数值.其他定义如下:typedef union _LARGE_INTEGER { struct { DWORD LowPart; LONG HighPart; }; LONGLONG QuadPart; } LARGE_INTE... 阅读全文
posted @ 2013-01-27 15:26 Leo Forest 阅读(421) 评论(0) 推荐(0) 编辑
摘要: tree.cpp// tree.cpp// After //poco/1.4/Foundation/samples/dir/src/dir.cpp//#include "Poco/DirectoryIterator.h"#include "Poco/File.h"#include "Poco/Path.h"#include "Poco/DateTimeFormatter.h"#include "Poco/DateTimeFormat.h"#include "Poco/Exception 阅读全文
posted @ 2013-01-22 20:18 Leo Forest 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 需要动态分配大小的得自己把转化封装一下,MinGW5下跑过.test.c#include <windows.h>#include <stdlib.h>#include <stdio.h>#include <locale.h>void print_hex(const UCHAR *buf, int len){ int i; for (i = 0; i < len; i++) { printf("0x%02x ", *(buf + i)); if (!((i + 1) % 4)) printf("\t") 阅读全文
posted @ 2013-01-18 11:58 Leo Forest 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 传送门:POCO Fanatic:http://poco.roundsquare.net/Demo地址:http://poco.roundsquare.net/2010/04/19/pocologger/ScopedLogMessage.h//// Copied from http://poco.roundsquare.net/2010/04/19/pocologger///#include <string>#include <memory>class ScopedLogMessage{public: ScopedLogMessage( const std::strin 阅读全文
posted @ 2013-01-18 10:05 Leo Forest 阅读(1685) 评论(0) 推荐(0) 编辑
摘要: 原文:http://www.cnblogs.com/pocobo/archive/2008/12/29/1364699.htmlPOCO C++库导游IntroductionA Guided Tour of the POCO C++ Libraries简介POCO C++库是开源的用于简化和加速C++开发面向网络、可移植应用程序的C++库集,POCO库和C++标准库可以很好的集成并填补了C++标准库缺乏的功能空隙。POCO库的模块化、高效的设计及实现使得POCO特别适合嵌入式开发。在嵌入式开发领域,由于C++既适合底层(设备I/O、中断处理等)和高层面向对象开发,越来越流行。当然POCO也准备 阅读全文
posted @ 2013-01-17 17:55 Leo Forest 阅读(1125) 评论(1) 推荐(0) 编辑
摘要: 原文:http://hi.baidu.com/taozpwater/item/d85d81bde4fd154b2bebe34e1、简介 class pair ,中文译为对组,可以将两个值视为一个单元。对于map和multimap,就是用pairs来管理value/key的成对元素。任何函数需要回传两个值,也需要pair。 该函数的相关内容如下所示: |->Type----->struct |->Include---> <utility> |->Define----> pair<calss first,calss second>(fir 阅读全文
posted @ 2013-01-16 09:18 Leo Forest 阅读(217) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 29 下一页