File: DataParallelUtils.smi

package info (click to toggle)
smlsharp 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 123,732 kB
  • sloc: ansic: 16,725; sh: 4,347; makefile: 2,191; java: 742; haskell: 493; ruby: 305; cpp: 284; pascal: 256; ml: 255; lisp: 141; asm: 97; sql: 74
file content (44 lines) | stat: -rw-r--r-- 1,565 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
_require "../../../../basis.smi"
_require "../../../../thread/main/myth.smi"

structure DataParallelUtils =
struct
  type stage (= int)
  val initialStage : stage
  val next         : stage -> stage
  val createStage  : unit -> stage ref
  val setNextStage : stage ref -> unit
  val isNewStage   : stage * stage -> bool

  structure DPBool =
  struct
    val orTrue   : (stage ref * stage ref) -> unit
    val andFalse : (stage ref * stage ref) -> unit
    val isTrue   : (stage ref * stage ref) -> bool
  end

  structure NextValueLock =
  struct
    type id = int
    type nextLock = {mutex: Myth.mutex, cond: Myth.cond}
    type 'a context = {getNextLock : id -> nextLock,
                       getStage : id -> stage,
                       setStage : (id * stage) -> unit,
                       setValue : id *'a -> unit,
                       getValue : id -> 'a}
    val createNextLock  : id ->  nextLock
    val destroyNextLocl : nextLock -> unit 
    val getMutex : 'a context -> id -> Myth.mutex
    val getCond  : 'a context -> id -> Myth.cond
    val getStage : 'a context -> id -> stage
    val getValue : 'a context -> id -> 'a
    val lock     : 'a context -> id -> unit
    val unlock   : 'a context -> id -> unit
    val signal   : 'a context -> id -> unit 
    val wait     : 'a context -> id -> unit
    val isReady  : 'a context -> stage ref * id -> bool 
    val putValue : 'a context -> stage ref * id * 'a -> unit
    val put      : 'a context -> stage ref * id * 'a -> unit
    val get      : 'a context -> stage ref * id -> 'a
  end
end