自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Guyf的专栏

有问题可以留言讨论

  • 博客(29)
  • 资源 (18)
  • 收藏
  • 关注

原创 c++11,线程池之二--有等待线程池中任务完成功能的线程池

#include #include #include #include #include #include class function_wrapper{ struct impl_base { virtual void call()=0; virtual ~impl_base() {} }; std::unique_ptr i

2015-11-28 19:55:05 1075

原创 c++11 线程池系列之一 所需要的join_threads

class join_threads{std::vector &threads;public: explicit join_threads(std::vector &threads_):threads(threads_){} ~join_threads() { for(unsigned long i = 0 ; i < threads.size();++i) { if(threa

2015-11-28 16:52:19 2018

原创 c++11 线程池系列之一 所需要的thread_safe_queue

templateclass thread_safe_queue{private: mutable std::mutex mut; std::queue> data_queue; std::condition_variable data_con;public: thread_safe_queue(){} thread_safe_queue(thread_safe_queue con

2015-11-28 16:50:59 4057

原创 c++11 线程池系列之一 最简单的线程池

线程池最简单的形式是含有一个固定数量的工作线程来处理任务,典型的数量是std::thread::hardware_concurrency().当有任务要处理时,调用一个函数将任务放到等待队列中。每个工作线程都是从该队列中取出任务,执行完任务后继续从等待队列取出更多的任务来处理。在最简单的情况,没有办法来等待一个任务完成。如需要这样的功能,则需要用户自己维护同步。下面上代码class t

2015-11-28 16:48:59 2870

原创 c++11,std::find的并行化模板化

#include templateIterator parallel_find_inter(Iterator first,Iterator last,MatchType match,std::atomic& done){try{ unsigned long const length = std::distance(first,last); unsigned long const mi

2015-11-28 11:05:38 837

原创 c++11,for_each的并行化,改写模板

template void parallel_for_each(Iterator first,Iterator last,Func f){unsigned long const length = std::distance(first,last);if(!length) return;unsigned long const min_per_thread = 25;if(len

2015-11-28 10:48:35 1213

原创 udp打洞,c++实现,Nat

#pragma once#include // 定义iMessageType的值#define LOGIN 1#define LOGOUT 2#define P2PTRANS 3#define GETALLUSER 4// 服务器端口#define SERVER_PORT 6060// Client登录时向服务器发送的消息struct stLoginMessage{

2015-11-28 10:29:23 2354 1

原创 c++11baohan线程安全的队列

#include "stdafx.h"#include #include #include #include templateclass threadsafe_queue{private: mutable std::mutex mut; std::queue> data_queue; std::condition_variable data_con;public: th

2015-11-27 22:44:24 661

原创 c++11 packaged_task 用法,将任务打包

#include std::mutex m;std::deque> tasks;templatestd::future post_task(Fun f){std::packaged_task task(f);std::future ret = task.get_future();std::lock_guard lk(m);tasks.push_back(std::move(tas

2015-11-27 16:49:34 2195 1

原创 c++11 async 的自带参数使用

class X{public: int foo(int a,std::string const& b){std::cout<<a<<std::endl<<b<<std::endl;return 3;} std::string bar(std::string const& a){std::cout<<a<<std::endl;return a;}}; X x; //在新线程中运行

2015-11-26 21:21:57 1074

原创 c++11使用 async异步函数并传递参数以及auto的使用方法

class X{public: int foo(int a,std::string const& b){std::cout<<a<<std::endl<<b<<std::endl;return 3;} std::string bar(std::string const& a){std::cout<<a<<std::endl;return a;}}; X x; //传入x是传入x的副本

2015-11-26 21:07:51 4750

原创 c++11 async启动异步任务的使用方法

#include std::future theAnswer = std::async(ihello); std::cout<<theAnswer.get()<<std::endl;当调用get()时,线程会阻塞直到异步线程结束。

2015-11-26 20:21:09 1716

原创 c++11future简单使用及介绍

唯一future:std::future此实例是仅有的一个指向其关联事件的实例,类似std::unique_ptr.共享future:std::shared_future多个实例可指向一个事件 。两种future变为就绪状态后无法恢复future本身非线程安全的,需要用户本身实现访问时的线程安全。

2015-11-26 20:13:51 1675

原创 c++11线程安全的队列的类的定义

#include #include #include #include templateclass threadsafe_queue{private: mutable std::mutex mut; std::queue data_queue; std::condition_variable data_con;public: threadsafe_queue(){} t

2015-11-26 16:46:56 1918

原创 c++11condition_variable的wait与lock类型的匹配

wait与std::unique_lock搭配使用,std::lock_guard并不提供与wait搭配使用的灵活性。

2015-11-26 16:22:37 1639

原创 c++11conditon_variable的wait在类中的等待条件

class X{data_con.wait(std::mutext,[this]{return xx;};};

2015-11-26 16:19:01 1699

原创 c++11条件变量的使用,condition_variable

void thread_prepare(int T){std::lock_guard lk(mt);data_queue.push(T);data_con.notify_one();}void thread_process(){while(1){std::unique_lock lk(mt);data_con.wait(lk,[]{return !data_queue.

2015-11-26 15:55:24 2168

原创 c++共享锁的使用

c++11未提供共享锁的实现,先使用boost的共享锁。#include boost::shared_mutex _mutex;boost::shared_lock mylock(_mutex);

2015-11-26 11:31:26 1059

原创 c++11只调用一次的函数

std::once_flag flag;std::call_once(flag,func_address);

2015-11-26 11:23:21 2345

原创 c++11细粒度的线程安全

void smallLockSize(){ std::unique_lock mylock(_mutex); hello(); mylock.unlock(); hello(); mylock.lock(); hello();}只有unique_lock可以使用细粒度的划分,即使用unlock以及locklock_guard等不可以

2015-11-26 11:03:27 534

原创 c++函数模板于类中的应用

class templateTest{public: template void process(func function) { function(); }}; templateTest tt; tt.process(hello);void hello(){ std::cout<<"hello"<<std::endl;}

2015-11-26 10:32:11 435

原创 c++11的mutex

#include #include std::list _list;std::mutex _mutex;void addList(int iValue){std::lock_guard guard(_mutex);_list.push_back(iValue);}bool list_contain(int valueToFind){std::lock_guard guard

2015-11-26 10:24:33 409

原创 c++调试重要武器GetLastError

GetLastError();通过获取错误码,快速定位错误

2015-11-24 11:01:19 702

原创 vector 中生成一大批线程并等待完成

void f(){ std::vector threads; for(int j = 0 ; j <= 20 ; j++) //生成匿名线程添加到vector中 threads.push_back(std::thread(hello)); //调用每个thread的join std::for_each(threads.begin(),threads.end(),std::mem_

2015-11-24 10:58:56 1062

原创 线程参数之 unique_ptr

void process(std::unique_ptr);std::unique_ptr p (new obj);std::thread t(process,std::move(p));p的所有权先进入 thread t,而后进入process.

2015-11-24 09:58:44 1282

原创 线程的引用

线程 std::thread无视了引用参数,将自动改为副本func(para& pa);如要传入引用参数应使用std::thread t(func,std::ref(parameter));

2015-11-24 09:52:38 559

原创 c++11线程管理,RAII方式等待异常环境下线程结束

直接上代码class thread_guard{private: std::thread& t;public: explicit thread_guard(std::thread& _t):t(_t){} ~thread_guard() { if(t.joinable()) t.join(); }private: thread_guard(thread_guard

2015-11-21 16:33:10 1378

原创 第一个 c++11多线程

// Consolehello.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include void hello(){std::cout}int _tmain(int argc, _TCHAR* argv[]){for(int k = 0 ; k {std::

2015-11-18 22:47:58 495

原创 类型转换c++

const_castdynamic_caststatic_castreinterpret_cast

2015-11-03 21:33:23 408

线程池,c++11,跨平台,支持vs12,g++最新的编译器,高效

c++11写的线程池,应用了c++11的新特性,对线程可接受任意可调用地址,可返回线程执行结果,具体文档见博客:http://blog.csdn.net/ozuoqi/article/details/50084691

2015-12-04

RFC3550_RTP协议中文版

RFC3550_RTP协议中文版

2015-09-22

算法导论试卷

某高校的研究生算法导论期末考试试卷,可以参考一下

2015-01-25

某高校信息检索课件及project及爬虫

某高校信息检索课件及project,很全的

2015-01-25

研究生数据库课件

国内某高校研究生课程,数据库的所有课件及作业project等。不适合入门使用

2015-01-25

某高校研究生课件计算机体系结构 量化研究方法

计算机体系结构 量化研究方法(第四版-英文版) 某高校研究生课件计算机体系结构 量化研究方法 可以参考一下

2015-01-25

计算机体系结构 量化研究方法(第四版-英文版).

计算机体系结构 量化研究方法(第四版-英文版).还有中文版的及答案,欢迎下载

2015-01-25

计算机系统结构——量化研究方法(第四版)答案英文版

计算机系统结构——量化研究方法(第四版)答案英文版.部分有些许错误,自行改正。。

2015-01-25

[中文版][第四版]计算机系统结构:量化研究方法

[中文版][第四版]计算机系统结构:量化研究方法,书本电子版,还有配套的答案在另一个连接里

2015-01-25

某C9高校机器学习的课件,ppt

某C9高校研究生课程的课件,机器学习课件,同考试复习资料共同发布,需要的可以下载

2015-01-25

某高校机器学习复习资料

某高校机器学习的期末考试复习资料,适合研究生阶段的复习及自我测试,有实体及答案

2015-01-25

Transact-SQL语句基础

(1)掌握利用各种数据类型声明局部变量的方法 (2)掌握为局部变量赋值的两种方法 (3)掌握常用系统函数、运算符和表达式的功能和应用 变量的应用 利用Transact-SQL语句声明一个长度为16的nchar型变量bookname,并赋初值为”SQL Server 数据库编程”。 运算符的应用,使用teaching数据库 查询生日在’1989-01-01’之后的学生信息; 3)系统函数的应用 编程计算任意两个日期的时间差,分别输出年,月,日的差值。 (4)编程求50到100之间多有能被3整除的奇数之和。(5)编写程序,根据姓名查询teaching数据库中学生的基本信息和选课信息,学生姓名通过变量输入。对于不存在的学生姓名输入值,打印提示信息。6)编写程序,查询所有学生选修课程的期末成绩和对应等级,如果学生为选修任何课程则输出提示信息。成绩和等级对应关系:final<60:‘不及格’;final>=60:‘及格’; final>=70:‘中’final>=80:‘良’;final>=90:‘优’。外连接使用LEFT JOIN实现。

2014-12-26

机器学习 第四章部分答案

机器学习的作业,第四章,部分答案。可以参考一下

2014-12-26

凸多边形三角划分

算法的project,凸多边形三角划分。 代码c++编写 ,vc6编译。有mfc的画图,也是vc6. 有详细的文档报告。

2014-12-26

rtp实现C 语言

rtp协议的c语言实现demo,有具体的样例,编译后直接执行即可

2014-11-16

信息检索导论答案 introduction to information retrieval

信息检索导论书答案 the answer about the book named introduction to information retrieval

2014-09-16

哈尔滨工业大学计算机研究生课程表

哈工大计算机研究所课表

2014-09-16

建立安卓可以使用的wifi的批处理文件

建立安卓可以使用的wifi的批处理文件,需要在本地网络点击右键,选择共享网络,再运行本批处理文件。默认半夜两点自动关机哦

2014-09-16

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除