J
jehugaleahsa
Hello:
At work we have run into an interesting "need". We have a bunch of
customers whose calculations affect one another. Now, to this time, we
have never and we may never have a scenario where two customers affect
one another. So, right now, our system can handle A affecting B.
However, we may someday need to handle A affects B and B affects A. Of
course, neither need to be totally calculated for the other to run.
Ideally, it would be nice to have a list or queue of customers, each
calculating in a different thread. At some deterministic point in a
customer's calculation, we would check to see if they are affected. It
would be nice to tell the thread to simply STOP. We could simply place
the paused thread at the back of the queue. Whenever its turn came
around again, it would be "guarunteed" that it could progress, so we
just unpause it.
In the current system we have to do a long, slow SQL to order
customers. However, this ordering doesn't handle inner-dependencies. I
would like to try to replace the slow SQL with this method, gaining
the benefit of solving the inner-dependency issue at the same time.
The only negative of doing things this way is the memory sitting
around in the inactive, partially completed thread. However, due to
some refactoring, my code only generates a very small memory footprint
until later in the calculation. Also, the number of inner-dependencies
will be small, so that isn't an issue (today).
How can I achieve my goal? Is there a way of doing this without
identifying the affecting customer? I just want to keep it simple by
putting the paused thread after all other threads. if it's not that
simple, let me know.
Thanks,
Travis
At work we have run into an interesting "need". We have a bunch of
customers whose calculations affect one another. Now, to this time, we
have never and we may never have a scenario where two customers affect
one another. So, right now, our system can handle A affecting B.
However, we may someday need to handle A affects B and B affects A. Of
course, neither need to be totally calculated for the other to run.
Ideally, it would be nice to have a list or queue of customers, each
calculating in a different thread. At some deterministic point in a
customer's calculation, we would check to see if they are affected. It
would be nice to tell the thread to simply STOP. We could simply place
the paused thread at the back of the queue. Whenever its turn came
around again, it would be "guarunteed" that it could progress, so we
just unpause it.
In the current system we have to do a long, slow SQL to order
customers. However, this ordering doesn't handle inner-dependencies. I
would like to try to replace the slow SQL with this method, gaining
the benefit of solving the inner-dependency issue at the same time.
The only negative of doing things this way is the memory sitting
around in the inactive, partially completed thread. However, due to
some refactoring, my code only generates a very small memory footprint
until later in the calculation. Also, the number of inner-dependencies
will be small, so that isn't an issue (today).
How can I achieve my goal? Is there a way of doing this without
identifying the affecting customer? I just want to keep it simple by
putting the paused thread after all other threads. if it's not that
simple, let me know.
Thanks,
Travis