How to determine the parent worker id of a worker thread?

0 views
Skip to first unread message

Steven Saviano

unread,
Aug 30, 2007, 4:20:13 PM8/30/07
to Google Gears
Hi Gears team,

Is there anyway do determine the parent worker id for a worker (i.e.,
the id of the worker that created that worker) within the worker?

So far, I have just been relying on 0 being the main thread id. But,
now, I have a case where I am creating a worker within a worker.

Any help is greatly appreciated. Thanks! :)
-- Steven

Aaron Boodman

unread,
Aug 30, 2007, 5:02:32 PM8/30/07
to google...@googlegroups.com
On Aug 30, 2007 4:20 PM, Steven Saviano <ssav...@gmail.com> wrote:
> Is there anyway do determine the parent worker id for a worker (i.e.,
> the id of the worker that created that worker) within the worker?

You can't. The only way to know is to look at who is sending you
messages (via the senderId param on the onmessage event). Relying on
zero is not a good idea, we don't promise to keep this true.

> I have a case where I am creating a worker within a worker.

Seriously!? :-)

- a

Steven Saviano

unread,
Aug 30, 2007, 5:48:38 PM8/30/07
to Google Gears

On Aug 30, 5:02 pm, "Aaron Boodman" <a...@google.com> wrote:


> On Aug 30, 2007 4:20 PM, Steven Saviano <ssavi...@gmail.com> wrote:
>
> > Is there anyway do determine the parent worker id for a worker (i.e.,
> > the id of the worker that created that worker) within the worker?
>
> You can't. The only way to know is to look at who is sending you
> messages (via the senderId param on the onmessage event). Relying on
> zero is not a good idea, we don't promise to keep this true.

Sounds good. Will do that.

>
> > I have a case where I am creating a worker within a worker.
>
> Seriously!? :-)
>

Seriously :) Not a different WorkerPool. Same WorkerPool - just more
workers.

> - a

Reply all
Reply to author
Forward
0 new messages