Skip to content

Commit 9a46b45

Browse files
committed
reindent in containers.thread
1 parent 59208fd commit 9a46b45

File tree

5 files changed

+228
-228
lines changed

5 files changed

+228
-228
lines changed

src/threads/CCBlockingQueue.ml

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ let with_lock_ q f =
4141
let push q x =
4242
with_lock_ q
4343
(fun () ->
44-
while q.size = q.capacity do
45-
Condition.wait q.cond q.lock
46-
done;
47-
assert (q.size < q.capacity);
48-
Queue.push x q.q;
49-
(* if there are blocked receivers, awake one of them *)
50-
incr_size_ q;
51-
Condition.broadcast q.cond)
44+
while q.size = q.capacity do
45+
Condition.wait q.cond q.lock
46+
done;
47+
assert (q.size < q.capacity);
48+
Queue.push x q.q;
49+
(* if there are blocked receivers, awake one of them *)
50+
incr_size_ q;
51+
Condition.broadcast q.cond)
5252

5353
let take q =
5454
with_lock_ q
5555
(fun () ->
56-
while q.size = 0 do
57-
Condition.wait q.cond q.lock
58-
done;
59-
let x = Queue.take q.q in
60-
(* if there are blocked senders, awake one of them *)
61-
decr_size_ q;
62-
Condition.broadcast q.cond;
63-
x)
56+
while q.size = 0 do
57+
Condition.wait q.cond q.lock
58+
done;
59+
let x = Queue.take q.q in
60+
(* if there are blocked senders, awake one of them *)
61+
decr_size_ q;
62+
Condition.broadcast q.cond;
63+
x)
6464

6565
(*$R
6666
let q = create 1 in
@@ -83,22 +83,22 @@ let push_list q l =
8383
| [] -> l
8484
| _::_ when q.size = q.capacity -> l (* no room remaining *)
8585
| x :: tl ->
86-
Queue.push x q.q;
87-
incr_size_ q;
88-
push_ q tl
86+
Queue.push x q.q;
87+
incr_size_ q;
88+
push_ q tl
8989
in
9090
(* push chunks of [l] in [q] until [l] is empty *)
9191
let rec aux q l = match l with
92-
| [] -> ()
93-
| _::_ ->
92+
| [] -> ()
93+
| _::_ ->
9494
let l = with_lock_ q
95-
(fun () ->
96-
while q.size = q.capacity do
97-
Condition.wait q.cond q.lock
98-
done;
99-
let l = push_ q l in
100-
Condition.broadcast q.cond;
101-
l)
95+
(fun () ->
96+
while q.size = q.capacity do
97+
Condition.wait q.cond q.lock
98+
done;
99+
let l = push_ q l in
100+
Condition.broadcast q.cond;
101+
l)
102102
in
103103
aux q l
104104
in aux q l
@@ -118,14 +118,14 @@ let take_list q n =
118118
if n=0 then List.rev acc
119119
else
120120
let acc, n = with_lock_ q
121-
(fun () ->
122-
while q.size = 0 do
123-
Condition.wait q.cond q.lock
124-
done;
125-
let acc, n = pop_ acc q n in
126-
Condition.broadcast q.cond;
127-
acc, n
128-
)
121+
(fun () ->
122+
while q.size = 0 do
123+
Condition.wait q.cond q.lock
124+
done;
125+
let acc, n = pop_ acc q n in
126+
Condition.broadcast q.cond;
127+
acc, n
128+
)
129129
in
130130
aux acc q n
131131
in
@@ -163,28 +163,28 @@ let take_list q n =
163163
let try_take q =
164164
with_lock_ q
165165
(fun () ->
166-
if q.size = 0 then None
167-
else (
168-
decr_size_ q;
169-
Some (Queue.take q.q)
170-
))
166+
if q.size = 0 then None
167+
else (
168+
decr_size_ q;
169+
Some (Queue.take q.q)
170+
))
171171

172172
let try_push q x =
173173
with_lock_ q
174174
(fun () ->
175-
if q.size = q.capacity then false
176-
else (
177-
incr_size_ q;
178-
Queue.push x q.q;
179-
Condition.signal q.cond;
180-
true
181-
))
175+
if q.size = q.capacity then false
176+
else (
177+
incr_size_ q;
178+
Queue.push x q.q;
179+
Condition.signal q.cond;
180+
true
181+
))
182182

183183
let peek q =
184184
with_lock_ q
185185
(fun () ->
186-
try Some (Queue.peek q.q)
187-
with Queue.Empty -> None)
186+
try Some (Queue.peek q.q)
187+
with Queue.Empty -> None)
188188

189189
let size q = with_lock_ q (fun () -> q.size)
190190

src/threads/CCLock.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ let update l f =
9191

9292
(*$T
9393
let l = create 5 in update l (fun x->x+1); get l = 6
94-
*)
94+
*)
9595

9696
let update_map l f =
9797
with_lock l
9898
(fun x ->
99-
let x', y = f x in
100-
l.content <- x';
101-
y)
99+
let x', y = f x in
100+
l.content <- x';
101+
y)
102102

103103
(*$T
104104
let l = create 5 in update_map l (fun x->x+1, string_of_int x) = "5" && get l = 6
105-
*)
105+
*)
106106

107107
let get l =
108108
Mutex.lock l.mutex;
@@ -135,7 +135,7 @@ let decr l = update l Pervasives.pred
135135
(*$T
136136
let l = create 0 in incr l ; get l = 1
137137
let l = create 0 in decr l ; get l = ~-1
138-
*)
138+
*)
139139

140140
let incr_then_get l =
141141
Mutex.lock l.mutex;

0 commit comments

Comments
 (0)