Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Change environment.Closer interface
Browse files Browse the repository at this point in the history
Changed the environment.Closer interface so that the `Close` method
return an error.
  • Loading branch information
samuelfneumann committed Sep 24, 2021
1 parent 79bbc7d commit 35df23c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion environment/Environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type PixelEnvironment interface {
// Closer is an environment which can be closed
type Closer interface {
Environment
Close()
Close() error
}

// RowColer is an environment that can return the rows and columns of
Expand Down
7 changes: 7 additions & 0 deletions environment/gym/Gym.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,10 @@ func (g *GymEnv) End(*ts.TimeStep) bool {
func (g *GymEnv) AtGoal(mat.Matrix) bool {
panic("atGoal: cannot calculate at goal for GymEnv")
}

// Close performs resource cleanup after the environment is no longer
// needed
func (g *GymEnv) Close() error {
g.Environment.Close()
return nil
}
4 changes: 3 additions & 1 deletion environment/mujoco/internal/mujocoenv/MujocoEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,11 @@ func (m *MujocoEnv) ActionSpec() environment.Spec {

// Close performs cleanup of MuJoCo resources once the environment
// is no longer needed.
func (m *MujocoEnv) Close() {
func (m *MujocoEnv) Close() error {
C.mj_deleteModel(m.Model)
C.mj_deleteData(m.Data)

return nil
}

// ID returns the ID of object with name name
Expand Down

0 comments on commit 35df23c

Please sign in to comment.