help w/ async message queue

  • While switching from NSConnection to YAMessageQueue, I ran into some
    problems and was hoping someone could help. I'm obviously doing something
    wrong (because my stuff crashes).

    I have something like this running in a new thread.

    while (1) {

    Data *data = [[Data alloc] init];

    [data set:value];

    [data set:another];

    [self updateProgress:data];

    }

    And in the base class of the above I do the following ...

    - (id) initWithObject:(id) mainObject

    {

        ...

    controller = mainObject;

    clientQueue = [controller messageQueue];

    messageQueue = [[YAMessageQueue alloc] init];

    [NSThread detachNewThreadSelector:@selector(threadMain:)

    toTarget:self withObject:nil];

    }

    clientQueue = [controller messageQueue];

    ...

    [[clientQueue proxyForTarget:controller] updateProgress:data];

    The above calls a method in my main thread (so that my thread can update the
    gui) ...

    - (void) updateProgress:(Data *) data

    {

    // gui updates ...

    }

    I have YAMessageQueue's in the main thread and the new thread so that I can
    communicate both ways.

    Anything wrong stand out?
  • It has a runloop, and the background thread is calling via YAMessageQueue.

    On Jan 18, 2008 11:53 AM, <marcelo.alves...> wrote:

    >
    > Hmm, I think you need a runloop and you can't use [self updateProgress]
    > from background thread (except if it is calling via YAMessageQueue)
    >
    > :: marcelo.alves
    >
    >
    > On Friday, January 18, 2008, at 02:10AM, "William Zumwalt" <
    > <wizumwalt...> wrote:
    >> While switching from NSConnection to YAMessageQueue, I ran into some
    >> problems and was hoping someone could help. I'm obviously doing something
    >> wrong (because my stuff crashes).
    >>
    >>
    >> I have something like this running in a new thread.
    >>
    >>
    >> while (1) {
    >>
    >> Data *data = [[Data alloc] init];
    >>
    >>
    >> [data set:value];
    >>
    >> [data set:another];
    >>
    >>
    >> [self updateProgress:data];
    >>
    >> }
    >>
    >>
    >> And in the base class of the above I do the following ...
    >>
    >>
    >> - (id) initWithObject:(id) mainObject
    >>
    >> {
    >>
    >> ...
    >>
    >> controller = mainObject;
    >>
    >> clientQueue = [controller messageQueue];
    >>
    >> messageQueue = [[YAMessageQueue alloc] init];
    >>
    >> [NSThread detachNewThreadSelector:@selector(threadMain:)
    >>
    >> toTarget:self withObject:nil];
    >>
    >> }
    >>
    >> clientQueue = [controller messageQueue];
    >>
    >> ...
    >>
    >> [[clientQueue proxyForTarget:controller] updateProgress:data];
    >>
    >>
    >> The above calls a method in my main thread (so that my thread can update
    > the
    >> gui) ...
    >>
    >>
    >> - (void) updateProgress:(Data *) data
    >>
    >> {
    >>
    >> // gui updates ...
    >>
    >> }
    >>
    >>
    >> I have YAMessageQueue's in the main thread and the new thread so that I
    > can
    >> communicate both ways.
    >>
    >>
    >> Anything wrong stand out?
    >>
    >>
    >
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today