package async_unix

  1. Overview
  2. No Docs
Monadic concurrency library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

async_unix-v0.16.0.tar.gz
sha256=a6a86202acea433b5c739ac20190a9a364da9d9eb7ebd402f517b8c58983839b

doc/src/async_unix/io_stats.ml.html

Source file io_stats.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
open Core

type t =
  { mutable total : Int63.t
  ; mutable char : Int63.t
  ; mutable fifo : Int63.t
  ; mutable file : Int63.t
  ; mutable socket : Int63.t
  }
[@@deriving sexp]

let create () =
  { total = Int63.zero
  ; char = Int63.zero
  ; fifo = Int63.zero
  ; file = Int63.zero
  ; socket = Int63.zero
  }
;;

let update t ~(kind : Fd.Kind.t) ~bytes =
  t.total <- Int63.(t.total + bytes);
  match kind with
  | Char -> t.char <- Int63.( + ) t.char bytes
  | Fifo -> t.fifo <- Int63.( + ) t.fifo bytes
  | File -> t.file <- Int63.( + ) t.file bytes
  | Socket _ -> t.socket <- Int63.( + ) t.socket bytes
;;

let total t = t.total

let get t ~(kind : Fd.Kind.t) =
  match kind with
  | Char -> t.char
  | Fifo -> t.fifo
  | File -> t.file
  | Socket _ -> t.socket
;;