My app builds a complex model based on socket input. Assume that the input comes regularly at two different time intervals, in a hourly interval and in a daily interval. The data is treated exactly the same, only that I want to build a "hourly" model and a "daily" model at the same time, in parallel. The simplest solution would be to duplicate the code with two different socket endpoints, in order to send the hourly and daily data to the different endpoints. Obiously this is not an elegant solution. So, is there an elegant way/design pattern/architecture that supports my purposes? The requirements would be as following:
1. Use the same code base to build different models at the same time, based on the type of input
2. At the same time process/cccessing the data of the models at a central place to draw conclusions/combine the models
I thought about letting the application run in two different threads, e.g. one to build the hourly and one to build the daily model.However, I don't want to share my variables between the threads. E.g. Currently my code stores the incoming data into a list, which is then further processed. So when the input is hourly and daily data, I don't want it to be mixed (otherwise I wouldn't get two separate models), but rather be treated separately (without duplicating my code or huge refactoring like making the code work for two instead of one input type). Basically I want my code to be scalable.
jeudi 23 août 2018
How to provide an own instance per variable to each thread (avoid sharing the heap in multi-threading)?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire