1// Copyright 2022 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package poll
6
7// Expose fdMutex for use by the os package on Plan 9.
8// On Plan 9 we don't want to use async I/O for file operations,
9// but we still want the locking semantics that fdMutex provides.
10
11// FDMutex is an exported fdMutex, only for Plan 9.
12type FDMutex struct {
13	fdmu fdMutex
14}
15
16func (fdmu *FDMutex) Incref() bool {
17	return fdmu.fdmu.incref()
18}
19
20func (fdmu *FDMutex) Decref() bool {
21	return fdmu.fdmu.decref()
22}
23
24func (fdmu *FDMutex) IncrefAndClose() bool {
25	return fdmu.fdmu.increfAndClose()
26}
27
28func (fdmu *FDMutex) ReadLock() bool {
29	return fdmu.fdmu.rwlock(true)
30}
31
32func (fdmu *FDMutex) ReadUnlock() bool {
33	return fdmu.fdmu.rwunlock(true)
34}
35
36func (fdmu *FDMutex) WriteLock() bool {
37	return fdmu.fdmu.rwlock(false)
38}
39
40func (fdmu *FDMutex) WriteUnlock() bool {
41	return fdmu.fdmu.rwunlock(false)
42}
43