close Warning: Can't synchronize with repository "(default)" (/project/cmucl/public_html/git/cmucl.git does not appear to be a Git repository.). Look in the Trac log for more information.

Opened 5 years ago

Closed 5 years ago

#77 closed enhancement (fixed)

Add JOIN-PROCESS

Reported by: sionescu Owned by: somebody
Priority: major Milestone:
Component: Core Version: 2013-03-a
Keywords: Cc:

Description

There should be a JOIN-PROCESS function that waits for a process to complete and returns its return value.

The current implementation in Bordeaux-Threads uses (mp:process-wait "..." (lambda () (not (mp:process-alive-p process)))), but that doesn't fulfill the second requirement.

Change History (4)

comment:1 Changed 5 years ago by sionescu

I added a workaround to Bordeaux-Threads, but it would be better to have this functionality in CMUCL itself:

(defun %make-thread (function name)
  (mp:make-process (lambda ()
                     (let ((return-values
                             (multiple-value-list (funcall function))))
                       (setf (getf (mp:process-property-list mp:*current-process*)
                                   'return-values)
                             return-values)
                       (values-list return-values)))
                   :name name))

(defun join-thread (thread)
  (mp:process-wait (format nil "Waiting for thread ~A to complete" thread)
                   (lambda () (not (mp:process-alive-p thread))))
  (let ((return-values
          (getf (mp:process-property-list thread) 'return-values)))
    (values-list return-values)))

comment:2 Changed 5 years ago by toy.raymond@…

  • Resolution set to fixed
  • Status changed from new to closed

commit 0232d2242e5acf9d1654cd0e4d7883de9e9f4705 Author: Raymond Toy <toy.raymond@…> Date: Sun Mar 24 09:43:33 2013 -0700

Fix ticket:77 by adding the code given in the ticket.

comment:3 Changed 5 years ago by sionescu

  • Resolution fixed deleted
  • Status changed from closed to reopened

Sorry I didn't specify that the code included was copied verbatim from Bordeaux-Threads. I make a proper patch available at https://github.com/sionescu/cmucl/commit/520441523f317e2c72c44c1d33516c3c0ce9da98

comment:4 Changed 5 years ago by toy.raymond@…

  • Resolution set to fixed
  • Status changed from reopened to closed

commit c94b32f927061d6e7b7ea1ebf92ccdb4c3b1a842 Author: Raymond Toy <toy.raymond@…> Date: Sun Mar 24 20:13:56 2013 -0700

Fix ticket:77 correctly, using the supplied patch link.

Note: See TracTickets for help on using tickets.