On Thu, Jul 19, 2001 at 11:53:42AM -0700, Todd Caine wrote:
> I just need some clarification. When writing a
> POE::Component. If the POE Session using the component just
> starts up and posts an event to the component, the only way
> for the Session to remain alive long enough to receive a
> postback is by either incrementing the SENDER's refcount and
> then decrementing it after we do the postback, or by storing
> the postback into the heap.
>
> In the Component that I'm trying to write I'm using
> $_[KERNEL]->refcount_increment($_[SENDER]->ID, 'keep_alive')
> in the state that's being posted to. If I postback to the
> SENDER in the same state and decrement the SENDER's refcount
> then the SENDER stays alive long enough to get the
> postback. If I don't post immediately back to the SENDER
> but still have the SENDER's refcount incremented shouldn't
> the SENDER stay alive until I decrement the refcount?
I would suggest either using an alias or use postbacks. Incrementing the
refcount manually doesn't seem to be very clean. Aliases and postbacks
increment the extra ref count. If you want to keep the component alive
and you don't want to use postback or selects and events in the queue won't
to the job, write something that hands out postbacks to your component,
through which clients talk to it.
I wrote such a thing some time ago i think. It works like an directory
service where you can register postbacks under a specific name and
interested clients can get a copy of the postback. you can implement
singletons or different instances per postback. however i never
completed it (its not a lot anyway), since i though it would be better to
do it right and write an object layer someday :)
Torvald