sem_init: ‘Function Not Implemented’

I’ve been doing some thread related code lately and just came across a problem. I’m using a semaphore for a producer/consumer solution around a shared resource, the build thread to be exact. So multiple producers are wanting to flag that a build needs to be done, but there’s only one consumer (the actual build thread).

Finished up all the code and then hit play only to find that my build thread ran continuously and never waited. In fact it would run without a call to build! After adding in some checks on return statements I find out that sem_init always fails when trying to create my semaphore: “Function Not Implemented.”

Turns out Apple decided not to implement unnamed semaphores :( Instead you’re supposed to use named semaphores. Well I’m not a fan! Named semaphores are available to other processes too. That means that two apps can both open the same named semaphore and interact (note: I haven’t actually tested if apps can ‘actually’ cross boundaries on iOS, but they can on other systems and portability is important for the engine). And since this is in generic engine code, I can’t just pick a really unique name cause it would clash between two or more games based on the same engine.

As the CEO of Yahoo recently stated, “that was certainly a downer.” Guess I’m going to have to come up with my own solution now.

 

Leave a comment

My View on Views

I was going over some GUI related code the other day and saw something I figured I could share with the world. Don’t design your views through inheritance. Design them through components instead. Not that this is GUI specific, but I tend to see the same problem again and again when people think about designing GUI related code.
(Read more…)

Leave a comment

Clipped Wings

Well it looks like Angry Birds has gotten their wings clipped and been bumped from #1 for a couple days straight now. The culprit is The Heist. I haven’t actually played it, so this is not a review or anything, although I really like their startup video (I was totally waiting for Jack Bauer to show up). I’m actually more impressed with how fast it’s gotten to #1.
(Read more…)

Leave a comment

The curiously recurring template pattern

Related to my previous post on expressive engine design, I found myself using the curiously recurring template pattern (CRTP) today. I say related because I believe the CRTP to be one of those beautiful and expressive templates out there in the c++ world.
(Read more…)

Leave a comment

Game engines shouldn’t be easy to use

I was talking with a friend the other day about some engine design stuff when he told me someone suggested to him to make his image packing system easier to use and package in sprite data as well. I don’t think that’s a very good at all. You should not design an engine to be easy to use. You should design your engine to be expressive!
(Read more…)

1 Comment

I Gest-Ure Gonna Like This!

Back to implementing gestures.  I’ve set up a general infrastructure to handle any sort of gestures the user might want to add in.  You create a gesture processor and then add some listeners to the processor to find out when certain events occur.  The important events are are for single occurrences, and ones for continuous events: start, continue, end, and cancel.  This allows you to handle single tap events versus a continuous drag.  But I want to extend things beyond just gestures.  I’m going to want to have something that picks into the scenegraph, as well as handling raw touch events so I can signal to a button that it should highlight on the initial touch down for example.  Well the cool thing about this system is that it simplifies the general code for trying to figure out what system should handle touch points.  Everything I described can be considered a gesture.  A picker gesture looks at any new touch downs and will pick into the scene to find relevant objects at that point.  Then the picker can send a single occurrence event to listeners to tell them which object it found.  Another gesture can just listen for raw touch events from the touch manager and then signal any listeners about what’s been heard.
(Read more…)

Leave a comment

To log or not to log

Well I’ve finally gotten some time to get back into a bit of programming.  I’ve been beating myself up cause I just haven’t had time with school, but now I’ve got a little bit of downtime so I plan on taking advantage of it.
Sadly, it had been so long since I had looked at any code that I had to do a quick review of what was there and where I left off.  Ahh yes, gestures!  Well I hit play and started to try out what was there … hmm gestures don’t work.  So next step is to start printing out some debug data of where I’m tapping.  But wait, I don’t really have any debugging utilities yet.  Well I think I found my project for tonight.
(Read more…)

Leave a comment