1 /* go-chan-cap.c -- the cap function applied to a channel.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
12 /* Return the cap function applied to a channel--the size of the
13 buffer. This could be done inline but I'm doing it as a function
14 for now to make it easy to change the channel structure. */
17 __go_chan_cap (struct __go_channel
*channel
)
25 i
= pthread_mutex_lock (&channel
->lock
);
28 if (channel
->num_entries
== 0)
32 /* One slot is always unused. We added 1 when we created the
34 ret
= channel
->num_entries
- 1;
37 i
= pthread_mutex_unlock (&channel
->lock
);