<div dir="ltr">Currently Host is implemented as a static class with lots of ifdefs to define different versions of methods depending on the OS and platform.<div><br></div><div>Has anyone ever thought about turning this into a a singleton that returns an actual instance of a class? This would provide a number of advantages, such as:</div>
<div><br></div><div>1) Cleaner code. You could use interfaces and inheritance to clearly define the common behavior of a Host, and allow each particular host to define its own platform specific functionality in derived implementations.</div>
<div><br></div><div>2) More flexibility for supporting non-trivial platform differences. As a quick example, currently launching a new process starts a monitoring thread, and passes data through type-erased batons and the like. This might not necessarily be an appropriate model for all platforms. Maybe I'd like to use one thread which I simply re-use for many different things, only one of which is monitoring processes.</div>
<div><br></div><div>3) Member data. Say you launch 10 processes. It would be useful if there were just handles to all 10 processes sitting in an easily accessible location (at least for Windows anyway, this would be useful). If there were a WindowsHost class, I could just have a list of HANDLE items in my class.</div>
<div><br></div><div>I'm sure there are many more benefits to doing so.</div><div><br></div><div>I'm still going over the class implementation, but I wanted to throw this out there for discussion. Let's say I did want to go forward with this refactor though. Anything I should keep in mind that isn't totally obvious?</div>
</div>