Skip to content

Commit

Permalink
Merge pull request #6 from issuu/travis-ci
Browse files Browse the repository at this point in the history
Add configuration for Travis CI
  • Loading branch information
Leonidas-from-XIV authored Jul 25, 2018
2 parents 7addd06 + bbf53d1 commit ecad8fc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: c
sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
global:
- DEPOPTS="*"
- TESTS=true
matrix:
- OCAML_VERSION=4.06
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Thread_pool
===========

[![Build Status](https://travis-ci.org/issuu/thread-pool-async.svg?branch=master)](https://travis-ci.org/issuu/thread-pool-async)

Creates an async thread pool so your blocking calls are contained in threads.

Dependencies
Expand Down
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(executable
(name test)
(preprocess (pps ppx_let))
(libraries alcotest alcotest-async thread_pool))
(libraries alcotest alcotest-async thread_pool core async_kernel async_unix))

(alias
(name runtest)
Expand Down
15 changes: 8 additions & 7 deletions test/test.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Base
open Core
open Async_kernel
open Async_unix

let unit_or_error =
(* exact error does not matter *)
Expand All @@ -13,8 +14,8 @@ let test_simple () =
let create () = Int.incr states in
let destroy () = Int.decr states in
let worker () =
Unix.sleepf 0.005;
`Ok (Int.incr jobs)
let%bind () = after (Time.Span.of_ms 5.) in
return @@ `Ok (Int.incr jobs)
in

let%bind pool = Thread_pool.init ~name:"unittest" ~threads ~create ~destroy in
Expand Down Expand Up @@ -43,8 +44,8 @@ let test_error () =
Int.incr errors;
failwith "Stop"
| _ ->
Unix.sleepf 0.005;
`Ok (Int.incr jobs)
let%bind () = after (Time.Span.of_ms 5.) in
return @@ `Ok (Int.incr jobs)
in

let%bind pool = Thread_pool.init ~name:"unittest" ~threads ~create ~destroy:ignore in
Expand All @@ -70,7 +71,7 @@ let test_retry () =
| false -> `Ok (Int.incr work_done)
in
should_fail := false;
result
return result
in
let%bind pool = Thread_pool.init ~name:"unittest" ~threads ~create ~destroy in
let%bind _result = List.init work_expected ~f:ignore |> Deferred.Or_error.List.iter ~how:`Parallel ~f:(fun () -> Thread_pool.with' ~retries:1 pool (worker (ref true))) in
Expand All @@ -89,7 +90,7 @@ let test_retry_fail () =
let destroy = ignore in
let worker () =
Int.incr tries;
`Attempt_retry
return `Attempt_retry
in
let%bind pool = Thread_pool.init ~name:"unittest" ~threads ~create ~destroy in
let%bind result = List.init work ~f:ignore |> Deferred.Or_error.List.iter ~how:`Parallel ~f:(fun () -> Thread_pool.with' ~retries:0 pool worker) in
Expand Down
1 change: 1 addition & 0 deletions thread-pool-async.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ depends: [
"ppx_let" {>= "v0.9" & < "v0.12"}
"alcotest" {test}
"alcotest-async" {test}
"core" {test & >= "v0.9" & < "v0.12"}
]

0 comments on commit ecad8fc

Please sign in to comment.