Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Making a C codebase reentrant by turning it into a big C++ object (phildawes.net)
31 points by fogus on Sept 21, 2009 | hide | past | favorite | 3 comments


The author didn't, as far as I understand, make the code reentrant. The code still operates on mutable state outside of the scope of the call such that two calls that pass in the same inputs may produce different results. The author simply refactored global variables into instance variables of a class, allowing him to create multiple instances of his original program's state.

Interesting to read nonetheless.


There's every chance I'm being sloppy with the term reentrant. The factor vm obviously isn't functionally-pure as it accepts user input so I guess it can't be called reentrant by that definition. You can start multiple copies of the program running in different threads though.


At the last paragraph he mentions he did make the code reentrant, just not getting in to detail...

I was also reading in hopes of how he changed that :/




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: