Skip to content

Commit

Permalink
Working on dereferencing session variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
bvds committed Feb 28, 2010
1 parent eb0041c commit 8ac7926
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Help/State.cl
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@
(defun do-close-problem ()
;; empty symbol table and entry list
(empty-symbol-table)
(fill **grammar** nil) ;shallow dereference, for garbage collection
(setf **grammar** nil)
(setq *StudentEntries* nil)
(fill *StudentEntries* nil) ;shallow dereference, for garbage collection
(setf *StudentEntries* nil)

;; unload current problem with its sgraph structures
;; Garbage collection for problems may be complicated,
;; since it may use stuff that is shared across problems
(setf *cp* NIL)

;; Set the current problem instance time from the universal time.
Expand Down
33 changes: 30 additions & 3 deletions Help/sessions.cl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
)

;; New method with
(defstruct help-env "Quantities that must be saved between turns of a session. Member vals contains list of values for help-env-vars."
;; Use type vector to make dereferencing easy.
(defstruct help-env ; (help-env (:type vector))
"Quantities that must be saved between turns of a session. Member vals contains list of values for help-env-vars."
section student problem vals)

;; Should be useful for debugging.
Expand Down Expand Up @@ -187,7 +189,7 @@
`(progn
;; Null webserver:*env* indicates that the student is trying to work
;; on a session that has timed out or has not been initialized:
(if (and webserver:*env* (help-env-p webserver:*env*))
(if (and webserver:*env* (help-env-p webserver:*env*)) ;(vectorp webserver:*env*))
(let ,(mapcar
#'(lambda (x) (list x '(pop (help-env-vals webserver:*env*))))
help-env-vars)
Expand Down Expand Up @@ -727,8 +729,33 @@
(:URL . "http://www.webassign.net/something/or/other"))
result)
result))
(fill (help-env-vals webserver:*env*) nil)
; (fill webserver:*env* nil)
; (dereference webserver:*env*)

;; Tell the session manager that the session is over.
;; Must be done after env-wrap
(setf webserver:*env* nil)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *dereferenced*) ;define symbol, but don't bind

(defun dereference (x)
(cond
((or (stringp x) (symbolp x) (numberp x)))
((consp x)
(dereference (car x)) (setf (car x) '*dereferenced*)
(dereference (cdr x)) (setf (cdr x) '*dereferenced*))
((vectorp x)
(loop for y across x do (dereference y) (setf y '*dereferenced*)))
;; Most structures are hard to think about, since
;; data may be shared across problems and they are
;; hard to derefernce.
((or (runtime-test-p x) (htime-p x) (turn-p x) (cmd-p x)
(Enode-p x) (SystemEntry-p x)
(MT19937:random-state-p x) ;random number generator seed
#+sbcl (sb-ext:process-p x))) ;solver process
(t
(format webserver:*stdout* "unknown type ~A for ~A~%" (type-of x) x))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 change: 1 addition & 0 deletions Help/symbols.cl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
(setf (cdr (get-variables-table x)) new-variables))

(defun empty-symbol-table ()
(fill *variables* nil) ;shallow dereference, for garbage collection
(setf *variables* (mapcar #'list *variable-namespaces*)))

;;-----------------------------------------------------------------------------
Expand Down

0 comments on commit 8ac7926

Please sign in to comment.