自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(257)
  • 收藏
  • 关注

原创 stl adapter 配接器

其实也就是适配器模式,即将一种接口转换为另一层接口的封装

2017-12-23 15:33:19 291

转载 stl 仿函数(函数对象)

定义(stl源码剖析):仿函数其实上就是一个"行为类似函数"的对象。即主体是对象,只是使用起来像一个函数。传递函数指针:templatebool compare_to(const T& x, const T &y) { return x > y;}templatevoid print_compare(T fun) { std::cout << fun(3

2017-12-23 14:00:21 237

原创 stl rebind 机制

作用:某个模板类接受一个策略已特化类型的类型(如内存分配器allocator),那么我需要使用相同的策略,但是类型需要被替换(重新绑定),这时候便可以使用rebind机制,来实现策略不变,而更换类型来得到需要的类型如:在我们使用相关容器的时候,如vector, map等,我们一般是不需要传入allocator类型的,因为会默认填入std::allocator,即std::a

2017-12-22 12:00:54 3493

转载 stl traits 萃取特征技术

定义:参考stl源码剖析,traits就像一台“特征萃取机”,榨取各个迭代器的特征(相应类型)如:简单模版的定义templateclass DemoTraits {typedef typename T value_type;} ;我们可以通过DemoTraits::value_type来得到模版的类型。这对于非指针类型是可以的那如果传入的是指

2017-12-21 21:08:56 375

原创 stl stl_construct.h 要点

stl_construct.h作用:对已分配的内存进行调用构造函数和析构函数操作调用构造函数::new(static_cast(__p)) _T1(std::forward(__args)...);以_p指针所执行的地址,使用_T1类型的构造函数(入参_args)进行初始化,即_p可以作为_T1类型使用了调用析构函数  std::_Destroy_a

2017-12-21 10:33:32 850

原创 HttpClient4 客户端出现TIME_WAIT

一、一般代码编写方式:CloseableHttpClient httpclient = HttpClientBuilder.create().build();HttpPost httpPost = new HttpPost(url);try { CloseableHttpResponse response = httpclient.execute(httpPost);

2017-09-26 15:26:45 2434

转载 __memcpy_sse2_unaligned - what does this mean in detail?

背景:出现段错误,展示出错位置在__memcpy_sse2_unaligned原因:一般这个原因是由于拷贝的memcpy拷贝的两个地址中出现了无效地址我出现的问题:address + offsset而offset是由int数值进行计算得到的,由于其中有些int值很大,那么相乘最大可能为2^32 * 2^32 = 2^64是会出现超过int的容量的,这

2017-08-09 14:31:55 4573

原创 自动生成.gitignore文件

https://www.gitignore.io/

2017-08-08 12:29:15 1116

转载 tcp头部没有数据长度信息

tcp头部没有长度信息,而udp有长度信息

2017-08-07 01:42:54 2533

原创 c++ template报错

一、场景template之前使用的时候都是正常的,然后引入crow库后,却报出error: expected ‘>’ before numeric constant二、定位bugg++ -E 查询模板:templateVT0编程了0000000三、通过ctags定位VT0发现VT0有两个文件被定义了:1./usr/include/x86_

2017-08-02 17:55:05 850

转载 java memory model

java memory modeljsr 133 FAQ

2017-08-01 00:02:31 201

原创 java concurrent-Callable FutureTask

一、简要说明Callable和FutureTask配合,完成异步方法调用并能获取到执行后的结果二、实现原理只是一个Runnable的特别的实现模式而已,并没有改变任何Thread->Runnable的方式从上图可以看到,FutureTask其实还是一个Runnable的实现类,故Thread还是能执行其run的方法,而Callable的call方法,其实是Fut

2017-07-23 16:44:45 267

原创 java concurrent-ThreadPoolExecutor

一、ThreadPoolExecutor注意的点:1.1 ctl(state:3|worker_num:29):1.1.1 state:线程池状态,32位前三位RUNNING(111),SHUTDOWN(000),STOP(001),TIDYING(010),ETRMINATED(011)1.1.2 worker_num:线程池中工作线程的数量,32位的后29位1.2

2017-07-23 16:33:57 310

原创 java concurrent-ConcurrentHashMap

一、数据结构下图(来自网络):简要说明:1.segments数组2.segment-散列表3.table-segment散列表的桶数组4.HashEntry-segment散列表发生冲突时候,使用链表解决冲突锁粒度-segment散列表segment加锁位置put和remove方法作用:多线程的竞争只在同一个segment中,且g

2017-07-22 22:49:41 316

原创 java concurrent-AtomicInteger

一、内容:主要简单说下AtomicInteger的getAndIncrement的实现方式二、跟随源码到达最深的位置:java入口:unsafe-java:unsafe-native-method:

2017-07-21 15:36:46 267

转载 汇编-x86指令查看

felixcloutier_x86:http://www.felixcloutier.com/x86/

2017-07-21 14:40:23 327

原创 openjdk-7编译

一、下载openjdkopenjdk7地址:http://download.java.net/openjdk/jdk7/openjdk-7-fcs-src-b147-27_jun_2011版本:http://www.java.net/download/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip

2017-07-21 11:29:15 1151

转载 ssh反向代理

背景:家里电脑没有公网ip,人在外面想连接家里的电脑做法:购买一台便宜的有公网ip的服务器(70+元)做法是家里电脑和公网服务器以ssh建立反向连接,这样公网服务器就知道家里的电脑位置,这样再通过公网的服务器来访问家里的电脑即可。1.在家里电脑,输入以下指令ssh -f -N -R 10000:localhost:22 public_ip@1

2017-07-13 19:49:03 518

原创 vim ctags

一、vim:tagsvim默认自带tags的常用指令,其需要用到的是tags文件tags文件内容格式为(每行):标签 文件路径 摘要描述 标签类型 标签格式化表示 标签的可见性如:因此如果发现tag指令没有打开对应位置,可以查看tags文件内容,查看标签是否没有被索引进去那么可以通过不断更改打tags命令的参数,来最终使目标标签都索引上vim中设置tags路径,

2017-07-09 02:33:06 478

原创 c __attribute__ __cleanup__

一、简单说明:cleanup作为__attribute__的其中一个可选属性值其作用的当其生命的变量离开了其生命周期,那么会自动调用你所指定的销毁函数二、例子:#include #include #include void destroy_string(char **str) { printf("final str : %s\n", *str);

2017-07-08 14:11:49 1533

原创 c 判断两个结构体内容相等(不能通过内存判断)

结构体typedef struct A { short short_num; int int_num;} A;A结构体为8字节, short_num自动补齐到4字节,而多余的2个字节,不会自动置为0如:#include typedef struct A { short short_num; int int_num;} A;int ma

2017-07-06 14:15:51 9952

转载 java中文乱码(linux环境下)

java中文乱码原因和解释-linux环境下

2017-07-01 15:59:05 4536

原创 jvm 闲聊

一、参数-Xmx:堆内容最大值,如:-Xmx4g-Xms:初始申请的堆内存大小,commited的内存,如:-Xms2g题外话:1.进程-Xmx2g -Xms2g2.top指令查看RES值,发现根本没有那么多内存被使用可能你会觉得奇怪,其实这没有什么写过c相关代码的,相信都试过malloc,当我们想内核申请内存的时候,申请完的内存如果没有被使用,是不会马上存放到内存

2017-06-21 14:38:20 257

转载 汇编-自定义section

1.1、语法格式    .section section_name[,"flags"[,%type[,flag_specific_arguments]]] 1.2、作用  定义一个段,每一个段以段名为开始,以下一个段名或者文件结尾为结束。  ELF格式允许的段标志: a:可分配             w:可写段

2017-06-19 12:04:28 6732

原创 汇编-地址

地址($)值获取:不需要$

2017-06-18 23:10:50 544

原创 汇编-Error: unsupported instruction `mov'

错误:Error: unsupported instruction `mov'刚开始学汇编出现的错误请检测你的movl指令是否写成了movl $1, $eax寄存器应该使用%,正确写法movl $1, %eax

2017-06-18 12:09:25 8439

原创 c strerror

string.hchar *strerror (int __errnum);打印错误码的字符描述

2017-05-14 23:18:07 232

转载 posix thread program

mark.日后细看转载链接:https://computing.llnl.gov/tutorials/pthreads/

2017-05-14 21:12:11 249

原创 c posix thread mutex cond rwlock

pthread.hmutex(互斥锁)int pthread_mutex_init(pthread_mutex_t *__mutex, const pthread_mutexattr_t *__mutexattr);对互斥锁进行初始化,例子:可以对互斥锁设置为递归锁(重入锁),默认互斥锁是不能重入的。int pthread_mutex_lock(pthread_mutex_

2017-05-14 18:23:30 432

原创 c 递归锁(重入锁) pthread_cond_wait 死锁

//1 threadpthread_mutex_lock(&mutex);pthread_mutex_lock(&mutex);pthread_cond_wait(&cond, &mutex);pthread_mutex_unlock(&mutex);pthread_mutex_unlock(&mutex);//2 threadpthread_mutex

2017-05-11 23:00:36 3213

转载 gcc LD_LIBRARY_PATH和LIBRARY_PATH区别

LIBRARY_PATH:编译期间需要查找.so或者.a文件LD_LIBRARY_PATH:运行期间需要查找.so文件转载地址:http://www.cnblogs.com/panfeng412/archive/2011/10/20/library_path-and-ld_library_path.html

2017-05-09 01:56:15 878

原创 c 函数别名

int test(int num) {return num;}1.define#define TEST testTEST(33);2.函数地址指针int (*testv2)(int) = test;testv2(33);3.__attribute__ ((__weakref__(""))), 弱引用static __typeo

2017-05-08 16:09:28 4139

转载 linux env和printenv(环境变量打印)

env和printenv均可以打印当前系统的环境变量转载地址:https://www.cyberciti.biz/faq/linux-list-all-environment-variables-env-command/mark

2017-05-08 11:54:39 7816

原创 c/c++ explicit

explicit 可用来阻止类构造函数的隐式转换如:class Test {public:Test(int num) : num_(num) {std::cout }Test(const Test &test) {num_ = test.num_;std::cout

2017-05-05 11:07:52 318

原创 cuda shared(共享内存)—一个容易错误的点

可能出现的代码情况:template__global__ void kCopy(int row_size, float **col_valuess, float *row_values) {int row_index = blockIdx.x * blockDim.x + threadIdx.x;if (row_index >= row_size) return;vol

2017-05-04 18:00:47 2665

原创 linux ctrl+r

ctrl+r 反向查询history的信息使用方式:ctrl + r输出关键词若发现不是要找,ctrl + r继续往回找,直到找到history的使用的方式history | grep "关键词"然后使用!数字,进行重新调用

2017-04-15 16:42:44 2055

转载 c 查看struct各字段的偏移值

typedef struct A {char a;char b;int c;} A;a的偏移值:&((A*)0)->ab的偏移值:&((A*)0)->bc的偏移值:&((A*)0)->c该操作并非会进行内存读取操作,因此不会出现core掉转载地址:http://www.linuxidc.com/Linux/2016-04/129845

2017-04-15 16:26:22 1036

翻译 cuda sm执行block的数量

原文:How many blocks a multiprocessor can process at once depends on how many registers per thread and how much shared memory per block are required for a given kernel since the multiprocessor's regis

2017-04-11 17:13:22 3792

翻译 cuda wrap执行方式

原文:At every instruction issue time, the SIMT unit selects a warp that is ready to execute and issues the next instruction to the active threads of the warp. A warp executes one common instruction at

2017-04-11 16:11:07 1501

原创 linux-whereis

whereis锁定二进制/源文件和手册文件的路径搜索路径/{bin,sbin,etc}/usr/{lib,bin,old,new,local,games,include,etc,src,man,sbin,X386,TeX,g++-include}/usr/local/{X386,TeX,X11,include,lib,man,etc,bin,games,emacs}

2017-04-11 10:56:56 203

空空如也

空空如也

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

TA关注的人

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