Faint~using a cross platform library but not cross platform

In these recent few months, we are busy with porting our project to Mac. Our project claims that it already takes cross platform into consideration as early as it’s in its frist release, because it is using some corss platform libraries(?!), such as ACE, which is famous. But it’s faint!! ACE eventually is not that very corss-platformed when we are fully dependent on ACE’s reactor pattern implementation, ACE_Reactor::register_handler to register event object and its handler for dispatch processing. Frankly speacking, it’s a side effect introduced by ACE_Reactor’s implementation on Windows. See:

#if defined (ACE_WIN32)

 

  /**

   * Register handler for OS events.

   *

   * Register an <event_handler> that will be notified when

   * <event_handle> is signaled.

   *

   * Reactor will call ACE_Event_Handler::add_reference() for a new

   * handler/handle pair.

   *

   * This interface is only available Win32 platforms because

   * ACE_HANDLE is an int on non-Win32 platforms and compilers are not

   * able to tell the difference between

   * register_handler(ACE_Event_Handler*,ACE_Reactor_Mask) and

   * register_handler(ACE_Event_Handler*,ACE_HANDLE).

   */

  virtual int register_handler (ACE_Event_Handler *event_handler,

                                ACE_HANDLE event_handle = ACE_INVALID_HANDLE);

 

#endif /* ACE_WIN32 */

The comment here is lying. The reason is that event dispatching is implemented based on an API – WaitForMultipleObjects, which does not have its equivalent implementation on Linux/Unix/Mac. You would say "there’s select on Linux/Unix/Mac that can be used as a demultiplexer". No, select only supports I/O demulitplex, not event objects. In fact, there’s no event object on Linux/Unix/Mac. If you need it, you have to simulate it with other premitive synchronous objects on Linux/Unix/Mac. Refer to http://www.ibm.com/developerworks/linux/library/l-ipc2lin2.html.

So here comes simulating events on Mac. According to our requirement, we need a named event object, so on Mac, it’s a named semaphore. There’s a good semaphore implementation conforming to POSIX standard (and System V – there’s two semaphore implementation, one for Sys V, one for POSIX) on Linux/Unix. But without Mac. (F**K!!和谐~) Take care!! sem_init, sem_timedwait, sem_getvalue are not implemented on Mac. But, in semaphore.h, you still can see the declerations for sem_init, sem_getvalue, and you can make your code pass compilation and linking, but again, not working. I can’t help shouting "你TM根本就没实现,还声明个P啊!". 仕方がない, why? Because it’s Mac.

Anyway, I overcomed all the above issues, and get my own implementation of Reactor work. Surely, only supports limited functionalities, and is somehow buggy. Take a look at it if you have interest. http://cid-2d6ee2561565d31c.skydrive.live.com/self.aspx/Library/MyReactor.zip

-Austin.D

该收心了

圣光普照 

话说,这个是大学时代曾经玩过的游戏。帐号注册已经5,6年了,还挺有感情的,汗。最近,一个人无聊的时候,经常会翻出来玩玩。从大年初一一直到现在,居然还4转了。完成了所有的4转职业任务。

回过头来的时候,感觉自己有些沉迷,所以是该开始收收心了,否则今年给自己制定的计划估计会完成不了。

不过,这4转的全屏技能,的确是很华丽的呀。啊哈哈哈~~

flumpool – 残像

 
风に吹かれなびく髪
柔らかな阳射し あの日と同じ景色
全ては心次第だよと 笑ってた君だけ消して
この身を削ってもと想える人さえも
いつかは逢えなくなる それが人生と
割り切れるものなど
想い出の中の何処かにも书いてないよ
爱してる 苦しくて 泣きたくて 24时间     
今まだ消せない 君が消えない この胸に
溢れ出す 想いはもう青空に呑み込まれて
届くことも无く 今は无い星のように 彷徨う残像(ひかり)
梦が终わり 目が覚めるように
忘れる事で 人は进んでくんだろう
それを许さないような出会いを
片方で望みながら
交わした约束を 残した伤迹を
抱きしめた记忆を 消す术を持たず
古ぼけた写真が 色褪せるように 心は出来て无くても
谁もが 涙を知ることで 大人になる
それが今だとして また一歩踏み出して
伝えよう 长く伸びた足迹を 振り返って
あのドアを开けて よかったんだと告げるその一瞬まで
本当に大切なモノを失った时に
人はもう生きられないと感じるけど
それでもやっぱり大切なモノの无い日々を 人は生きれないんだよ
仆らは谁かを爱することで确かめてる
鼓动が叫んでる 此処にいると叫んでる
爱してる 爱してる
爱しすぎた あの季节で
この胸焦がすほど 梦の中で闻いていた
溢れ出す 想いはもう青空に呑み込まれて
届くことも无く 今は无い星のように 彷徨う残像(ひかり)