A new hope

This week I finally got arround to giving a new, fresh structure to the mod_parrot module code. I have complained, perhaps not loudly enough, about the various inadequacies of the old codebase, mostly with regards to extensibility. A cleanup was needed. As such, here is a walkthrough of the new structure, also serving as documentation.

Interpreter instantiation, initialization, pooling and destruction happens in mod_parrot_interpreter.c. This file has an implementation of a thread-safe interpreter pool. At least, I hope it is thread-safe, because I cannot test it (yet). Public symbols are mod_parrot_interpreter_acquire() and mod_parrot_interpreter_release(). In short, I use short-lived single-interpreters.

Determining whether a request should be accepted, and if so where it should lead is handled by the mod_parrot_find_route function in mod_parrot_route.c. This function returns a mod_parrot_route structure, which is essentially an array of strings containing the requested language, filename, and if specified class name and routine name. Note that the last of these are not yet done, but should be relatively easy to add.

Library loading, starting the loader script and error reporting all happen in mod_parrot_run.c. Public functions are mod_parrot_run(), mod_parrot_preload() and mod_parrot_report().

Lastly, IO glue still happens in mod_parrot_io.c, using mod_parrot_open_input(), mod_parrot_read(), and mod_parrot_write(). This part was pretty much unchanged.

So, whats next? Unfortunately the soft 'pencils down' date is monday already. I would have liked adding a lot of new features, however time kept me from doing that. With the new structure in place, there are however many more logical extension points.

One of the things that I want to do is determine the compiler by the contents of the script file, by means of the hash-bang (#!) line present in many scripts. I'd like to open up error reporting to a possible user script. And I'd like to specify options for configuring the PSGI application used by mod_parrot, in effect filling the route. By the time of the next post, I will hopefully have done some of these things.