CLIM mail archive

[Prev][Next][Index][Thread]

locks



    Date: Tue, 1 Sep 1992 10:34 EDT
    From: abbott@aero.org


    | 
    | I have an application which uses two processes.  Since converting to CLIM i have
    | a new problem which might be related to the fact that both processes can 
    | be simultaneousely effecting the panes output history--yes this could be changed
    | but it would require a great deal more work than i presently have budget for--.
    | I saw the messages about using locks when interacting with the screen.  Could
    | someone provide a short snippet of code showing how one would use those 
    | unexported clim calls initial-lock-values and with-lockf? I understand how
    | locks work but I don't have the foggiest which resources I need to associate
    | with the lock in order to insure that one process doesn't change the output 
    | history record while the other process is trying to access it.  Thanks.
    | 

    I wrote the question to which locks were the answer.  I had the same
    problem you do.  Instead of using Clim locks, I used the locks in
    Allegro's multi-processing system.  Since you have a multi-process
    application, your lisp must have some sort of lock mechanism.  My code
    is very simple.

This doesn't do you any good for CLIM 1.0/1.1, but you should use
CLIM-SYS:MAKE-LOCK and CLIM-SYS:WITH-LOCK-HELD in CLIM 2.0, since
they are portable across all platforms that implement CLIM.

    In Allegro, mp is the multiprocess package.

      ;; This creates a globally accessible lock.
      (defvar display-lock (mp:make-process-lock))

    In one process:

      ;; This waits until the lock is available before executing the body.
      ;; It then grabs the lock, locking out any other process that needs
      ;; this lock.  (display-line write to the 'messages pane in IDM-frame.)
      (mp:with-process-lock (display-lock)
	   (mapc #'(lambda(L) (display-line L Stream)) Lines))

    In the other process:

      ;; Same here.
      (mp:with-process-lock (display-lock)
	   (redisplay-frame-pane IDM-frame (get-frame-pane IDM-frame 'messages)))


    It seems to work!

    -- Russ

0,,

Follow-Ups: References:

Main Index | Thread Index