简介 googletest是Google公司开发的一款跨平台的c++测试框架。 依赖 Bazel或者CMake(通常用cmake) 支持c++11标准的编译器 安装 下载 git clone https://github.com/google/googletest.git 编译 cd googlet ...
分类:
其他好文 时间:
2020-06-21 09:55:58
阅读次数:
189
直接把注释写到代码中: 1 int 2 __pthread_mutex_lock (pthread_mutex_t *mutex) 3 { 4 unsigned int type = PTHREAD_MUTEX_TYPE_ELISION (mutex); 5 6 //安全检查 7 LIBC_PROB ...
分类:
其他好文 时间:
2020-06-20 21:54:01
阅读次数:
156
获取进程ID: 原型: #include <unistd.h>pid_t getpid(void); 返回调用进程的进程ID。 获取线程ID: 原型: #include <pthread.h>pthread_t pthread_self(void); 返回调用线程的线程ID。 ...
分类:
编程语言 时间:
2020-06-19 16:14:13
阅读次数:
93
pthread_create是类Unix操作系统(Unix、Linux、Mac OS X等)的创建线程的函数。它的功能是创建线程(实际上就是确定调用该线程函数的入口点),在线程创建以后,就开始运行相关的线程函数。 头文件: #include<pthread.h> 函数原型: int pthread_ ...
分类:
其他好文 时间:
2020-06-19 16:10:58
阅读次数:
52
互斥锁(互斥量) 创建互斥锁 pthread_mutex_t mutex; 初始化互斥锁 pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr); 销毁互斥锁 pthread_mutex_unlock(p ...
分类:
编程语言 时间:
2020-06-13 00:08:25
阅读次数:
67
qt有自己的线程实现方式,但有时候我们由于某些原因,会用到pthread来实现多线程。 我把自己看到过的pthread使用方法记下来。如果你有更好的方法,或觉得此方法有什么缺点,请在评论区指出。 这个类去掉了一些冗余代码,编译时可能出现小错误。 CRecvJson.cpp 1 #include "R ...
分类:
其他好文 时间:
2020-06-10 12:45:03
阅读次数:
128
iOS 中实现线程安全 实现线程安全可以通过加锁、单线程访问等方式。 iOS 中常用的几种锁: os_unfair_lock pthread_mutex dispatch_semaphore NSLock NSRecursiveLock NSCondition NSConditionLock @sy ...
分类:
移动开发 时间:
2020-06-09 00:00:51
阅读次数:
216
下载pkg文件 https://golang.google.cn/dl/ sudo vim /etc/profile 11 export GOROOT=/usr/local/go 12 export GOPATH=${GOROOT}/gopath 13 export PATH=$PATH:${GOR ...
分类:
系统相关 时间:
2020-06-05 20:57:54
阅读次数:
185
方法一 PROJECT(HELLO) set(CMAKE_CXX_FLAGS "${CAMKE_CXX_FLAGS} -std=c++11") AUX_SOURCE_DIRECTORY(. SRC_LIST) ADD_EXECUTABLE(hello ${SRC_LIST}) 从cmake的CMak ...
分类:
编程语言 时间:
2020-05-30 15:43:04
阅读次数:
85
一、createprocess BOOL CreateProcess( LPCTSTR lpApplicationName, // name of executable module //要创建的进程名称 LPTSTR lpCommandLine, // command line string // ...