-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always acquire lock before using PicoSAT object
- Loading branch information
1 parent
141dccb
commit 185788d
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,23 +294,23 @@ func (p *Pigosat) Assume(lit Literal) { | |
// more effective. The function can only be called as long the current | ||
// assumptions are valid. See Assume() for more details. | ||
func (p *Pigosat) FailedAssumption(lit Literal) bool { | ||
defer p.ready(true)() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
justinfx
Contributor
|
||
// Will SIGABRT if user calls this without the solver being | ||
// in the Unsatisfiable state | ||
if p.Res() != Unsatisfiable { | ||
return false | ||
} | ||
defer p.ready(true)() | ||
return C.picosat_failed_assumption(p.p, C.int(lit)) != 0 | ||
} | ||
|
||
// Returns a list of failed assumption in the last call to | ||
// Solve(). It only makes sense if the last call to Solve() | ||
// returned Unsatisfiable. | ||
func (p *Pigosat) FailedAssumptions() []Literal { | ||
defer p.ready(true)() | ||
if p.Res() != Unsatisfiable { | ||
return nil | ||
} | ||
defer p.ready(true)() | ||
|
||
litPtr := C.picosat_failed_assumptions(p.p) | ||
return p.litArrayToSlice(litPtr) | ||
|
Why was this change necessary? Res() is a public function that acquires its own read lock. Do we need to lock twice? I always thought that it is best to not call functions which in turn acquire the lock that was already acquired in the calling function.