WengQiang's Blog

where there is a will, there is a way!

default actions to signals

  1. almost all signals in POSIX. 1-1900, the default is to terminate without or with core dump.
  2. few signals are ignored like SIGCHLD
  3. SIGSTOP cause the program to suspend and SIGCONT to continue. common situation is use CTRL-Z in shell

c++11 threads

Eli Bendersky's website: C++11 threads, affinity and hyperthreading

c++11 thread_local

目前使用编译器的选项设置:windows:*__declspec(thread)* linux: *__thread*

使用recursive_mutex问题

task A wants to modify a shared data structure and take a lock on its recursive mutex. It then blocks on some OS call; the task gets taken off current thread, and task B start executing. task B take a lock on the same recursive mutex successfully because it executed on the same thread, then it will reads or modify the data which was in the middle of being modified by task A, then a disaster happen!

阅读全文 »

配置toolchain

一般在mac下选择 MacOSX GCC, linux 下选择Linux GCC 1. 然后可以配置gcc (可以自己源码编译或者下载编译好的hpc gcc)hpc gcc hpc-gcc

  1. 配置eclipse使用该版本gcc
  • 配置preference(应用于全部项目) eclipse preference

  • 配置项目的属性(应用于单个项目) eclipse project property

删除一整行

  1. 使用shutcuts:command + d
  2. 按鼠标左键3下,然后按delete键
阅读全文 »

create new object or modify the object

  • create new object > slice operator([:]); + operator;

dir 和 help 函数

  1. var = ''; dir(var) 可以输出var那个object中的所有方法。
  2. var = ''; ty = type(var); help(ty.method) 可以输出var的类型中method的相关信息。
阅读全文 »

判断一个表达式是lvalue or rvalue

A useful heuristic to determine whether an expression is an lvalue is to ask if you can take its address. If you can, it typically is. If you can’t, it’s usually an rvalue.

一般情况下, 可以根据以上所述进行判断。

关于exception safe

如果一个函数是exception safe的,则它表示提供basic exception safety guarantee ,至少要保证:即使函数有exception抛出,pragram invariants remain intact(比如: 没有数据结构出错) and no resources are leaked 如果函数提供strong exception safety guarantee, 则保证:if an exception arises, the state of the program remains as it was prior to the call.

decltype

int x = 0

阅读全文 »
0%