kimanaw has asked for the wisdom of the Perl Monks concerning the following question:
As the doco's say, thread shared objects can't be blessed. And only scalars can be passed on Thread::Queues.
I've got a multithreaded server architecture (sortof a publish/subscribe, or perhaps observer/observable pattern). A request comes in, I turn it into a perl object, then have to give multiple configurable modules a chance to fiddle with it, possibly with long latency operations. When they're all done fiddling, the resulting request object gets marshalled and forwarded out the backend.
Problem is, I need a way to post the request object to the fiddler modules so they can each play their tune, and the request object just waits til everyone finishes.
Since I can't share the blessed object with the fiddler threads, the only thing I can think of is to somehow marshall the interesting bits out of the request object into a shared hash, and have each fiddler thread create a "shadow" request object to provide fiddling methods, then send it all back up to the original request object again. (Slow, painful, very likely error prone).
Can anyone recommend an alternative method/pattern to accomplish this (aside from jumping to Javayukfoo) ?
|
|---|