GCC4.4发布了。看了点多线程编程

GCC4.4发布之后那段时间写的一个blog:

 

日期:2009-04-24

 

 GCC4.4发布了。看了点多线程编程 

 

GCC4.4发布了。

支持了部分C++0x特性。千呼万唤始出来啊,等死我了。(虽然我最初是在等VC2010的消息,并没怎么关注GCC)

虽然支持的还不全,有些很重要的东西比如lambda和concept都还很不完善,但是至少开始做了,看到了曙光啊。

下了个别人编译的miniGW版本,试了下。

auto支持了,用着非常爽。相应地,decltype也支持了:decltype(8+3.5) f;//定义一个浮点变量f
rvalue也基本上支持了,试了下没什么问题。
多线程据说有大改进可惜没仔细关注。
初始化列表也被支持了,这下就可以为自己的类的构造使用初始化列表了,vector也可以用{}初始化了。
constructor支持default和delete指定了,但是我很看重的代理构造器还没被支持,郁闷。
variadic templates也是个很爽的东西,不过貌似我目前还用不着。

那个右尖括号就不说了,貌似VC2005就已经解决了。

lambda按照官方的说法是“Some Development”,但是我试了几种方式貌似都不能编译通过。concept没试,估计可能也支持不好。看来得等下个版本了。


总之很欣慰,很期待。

----------------------------------------

最近不知怎的阴差阳错的开始关注C++的多线程编程。
发现的确很令人头晕。
那个volatile才纠缠完毕,又在某文上看到说这玩意不能保证多线程没问题。
又扯到memory barrier那里去看了半天,不过又和另外一个关于C++0x多线程模型的文章有所纠结。


另外一篇ridiculous fish的blog也看得有些晕呼呼的,摘录一下那里面的结论吧。


  • The compiler and the processor both conspire to defeat your threads by moving your code around! Be warned and wary! You will have to do battle with both.
  • Even so, it is very easy to mask serious threading bugs. We had to work hard, even in highly contrived circumstances, to get our bug to poke its head out even occasionally.
  • Ergo, testing probably won’t catch these  types of bugs. That makes it more important to get it right the first time.
  • Locks are the heavy tanks of threading tools --- powerful, but slow and expensive, and if you’re not careful, you’ll get yourself stuck in a deadlock.
  • Memory barriers are a faster, non-blocking, deadlock free alternative to locks. They take more thought, and aren’t always applicable, but your code’ll be faster and scale better.
  • Memory barriers always come in logical pairs or more. Understanding where the second barrier has to go will help you reason about your code, even if that particular architecture doesn’t require a second barrier.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值