Skip to content

Commit

Permalink
Merge pull request #8 from msakai/improve-glpk-thread-safe-test
Browse files Browse the repository at this point in the history
improve case_glpk_thread_safe test a little
  • Loading branch information
msakai committed Dec 26, 2020
2 parents 80587ed + 3985bcb commit 374139c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions MIP-glpk/test/TestSuite.hs
@@ -1,4 +1,4 @@
-- {-# OPTIONS_GHC -Wall -Wno-unused-top-binds #-}
{-# OPTIONS_GHC -Wall -Wno-unused-top-binds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
Expand Down Expand Up @@ -50,16 +50,19 @@ case_glpk_infeasible = do

case_glpk_thread_safe :: Assertion
case_glpk_thread_safe = when rtsSupportsBoundThreads $ do
t <- asyncBound $ do
ret <- Raw.glp_init_env
ret @?= 0
th1 <- asyncBound $ do
Raw.glp_init_env >>= (@?= 0)
Raw.glp_init_env >>= (@?= 1)
th2 <- asyncBound $ do
ret <- Raw.glp_init_env
ret @?= 0
void $ Raw.glp_free_env
Raw.glp_init_env >>= (@?= 0)
Raw.glp_init_env >>= (@?= 1)
_ <- Raw.glp_free_env
Raw.glp_init_env >>= (@?= 0)
wait th2
void $ Raw.glp_free_env
wait t
Raw.glp_init_env >>= (@?= 1)
_ <- Raw.glp_free_env
Raw.glp_init_env >>= (@?= 0)
wait th1

-- ------------------------------------------------------------------------

Expand Down

0 comments on commit 374139c

Please sign in to comment.