Re: XForms: Threadsafe

From: Antonio Buitrago (antonio@tgi.es)
Date: Thu Jun 01 2000 - 07:26:02 EDT

  • Next message: Dick Middleton: "XForms: TAB navigation"

    # To subscribers of the xforms list from Antonio Buitrago <antonio@tgi.es> :

    I have solved a similar problem using this (Chapter 4 in XForms Manual):

    1.- Connect a function to "fd" :

    static int fd;

    int inicRefrescoForms ()
    {
         ...
        fl_add_io_callback (fd,FL_READ,
                            (FL_IO_CALLBACK)refresca_forms_io_callback,
                            NULL);
       return OK;
    }

    2.- The callback function waits for a message from "fd":

       The structure "msj" (in below function) is a message which contain the "what
    to do" information.

    void refresca_forms_io_callback (int fd, void * dato)
    {
      TD_msj_refresco msj;
      int nBytes;

        if ((nBytes = read(fd, &msj, sizeof(msj))) > 0)
        {
          switch (msj.form)
          {
            case FORM_PPAL:
                  refresca_ppal(&msj);
                 break;
            case FORM_INICIAL:
                  refresca_inicial (&msj);
                 break;
            case FORM_CALIBRACION:
                 refresca_calibracion (&msj);
                 break;

       ....

    }

    void refresca_ppal(TD_msj_refresco *msj)
    {

       switch (msj->comando)
       {
             case PPAL_REFRESCA_FECHA:
              fl_set_object_label (fd_ppal->text_fecha, (char *)msj->args);
              break;

        ....

       }
    }

    3.- Now you can send a "msj" from a thread to Xforms.

            I hope it helps you (Sorry my bad english).

            A. Buitrago

    Paolo Prandini wrote:
    >
    > I implemented a big program using XForms whose purpose is to control some
    > industrial machinery; the same Linux PC running X is also controlling the
    > I/O
    > (motors, lights, etc).
    > I need to show some real time values and alarms in the same window where
    > are located the pushbuttons activating the various functions .
    > I didn't even think of it, but in fact I designed everything as if
    > XForms were threadsafe.
    > BUT IT IS NOT! Now I have some mysterious lockups and I traced them to
    > this kind of problem.
    > The possible solutions are:
    > a) rewrite everything with another lib that is threadsafe
    > b) fix XForms
    > But to fix XForms I need the source code! What about letting me do this
    > kind of modification? Or maybe there is a threadsafe version in the works?
    > Thanks for any suggestion.
    > Paolo Prandini
    > prandini@spe.it
    >
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Thu Jun 01 2000 - 07:31:27 EDT