Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

it is very predicatable.. Every call it returns buffer, after 8 calls it wraps. I use such stuff in many places.. GUI programs.. daemons.. Most stuff are single threaded. If threads are used, they are really decupled from each other.

Yes, you should never ever use it in Library.. But small utility functions should be okish :)

This is example from my Ruby graph library. GetMouseEvent can be called alot, but I need at most 2 results. Its Ruby, so I can either dynamicaly allocate objects and let GC pickup them later, or just use static stuff here, no GC overhead. it can be called 100s of times per second, so its worth it.

  static GrMouseEvent evs[8];
  static int z=0;
  GrMouseEvent *ev=&evs[z];


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: