Skip to content

Commit

Permalink
Migrate systems to init/discard flows where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Oct 3, 2018
1 parent 33de4ee commit 1f07e50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
38 changes: 17 additions & 21 deletions graphics/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@
(:default-initargs :depends-on '(host-system)))


(defmethod initialize-system :after ((this graphics-system))
(defmethod enabling-flow list ((this graphics-system))
(with-slots (resource-executor) this
(setf resource-executor (acquire-executor :single-threaded-p t :exclusive-p t))))
(>> (%> ()
(setf resource-executor (acquire-executor :single-threaded-p t :exclusive-p t))
(execute resource-executor
(lambda ()
(bind-rendering-context :main nil)
(log:debug "Shared context bound")
(run (concurrently () (continue-flow))))
:priority :highest :important-p t))
(for-host ()
(framebuffer-size))
(-> this (viewport)
(declare (type vec2 viewport))
(update-context-framebuffer-size (floor (x viewport))
(floor (y viewport)))))))


(defmethod disabling-flow list ((this graphics-system))
Expand All @@ -31,9 +44,9 @@
(progn
(release-rendering-context)
(log:debug "Shared context released"))
(continue-flow)))
(run (concurrently () (continue-flow)))))
:priority :highest :important-p t)
(continue-flow)))
(run (concurrently () (continue-flow)))))
(instantly ()
(release-executor resource-executor)))))

Expand All @@ -48,23 +61,6 @@
,@body))


(defmethod enabling-flow list ((this graphics-system))
(with-slots (resource-executor) this
(>> (%> ()
(execute resource-executor
(lambda ()
(bind-rendering-context :main nil)
(log:debug "Shared context bound")
(continue-flow))
:priority :highest :important-p t))
(for-host ()
(framebuffer-size))
(-> this (viewport)
(declare (type vec2 viewport))
(update-context-framebuffer-size (floor (x viewport))
(floor (y viewport)))))))


(defmethod dispatch ((this graphics-system) (task function) invariant &rest args
&key (main-p t) disposing)
(with-slots (resource-executor) this
Expand Down
2 changes: 1 addition & 1 deletion host/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@


(defmethod disabling-flow list ((this host-system))
(ge.ng:>>
(>>
(%> ()
(bodge-host:destroy-shared-rendering-context (shared-application this))
(set-destroy-continuation (host-application this) #'continue-flow)
Expand Down

0 comments on commit 1f07e50

Please sign in to comment.