Debian Codegraph @

compiler/natives/src/internal/poll/fd_poll_js.go

raw
1 // +build js
2
3 package poll
4
5 import "time"
6
7 // pollDesc is a no-op implementation of an I/O poller for GOARCH=js.
8 //
9 // Its implementation is based on NaCL in gc compiler (see GOROOT/src/internal/poll/fd_poll_nacl.go),
10 // but it does even less.
11 type pollDesc struct {
12 closing bool
13 }
14
15 func (pd *pollDesc) init(fd *FD) error { return nil }
16
17 func (pd *pollDesc) close() {}
18
19 func (pd *pollDesc) evict() { pd.closing = true }
20
21 func (pd *pollDesc) prepare(mode int, isFile bool) error {
22 if pd.closing {
23 return errClosing(isFile)
24 }
25 return nil
26 }
27
28 func (pd *pollDesc) prepareRead(isFile bool) error { return pd.prepare('r', isFile) }
29
30 func (pd *pollDesc) prepareWrite(isFile bool) error { return pd.prepare('w', isFile) }
31
32 func (pd *pollDesc) wait(mode int, isFile bool) error {
33 if pd.closing {
34 return errClosing(isFile)
35 }
36 return ErrTimeout
37 }
38
39 func (pd *pollDesc) waitRead(isFile bool) error { return pd.wait('r', isFile) }
40
41 func (pd *pollDesc) waitWrite(isFile bool) error { return pd.wait('w', isFile) }
42
43 func (*pollDesc) waitCanceled(mode int) {}
44
45 func (*pollDesc) pollable() bool { return true }
46
47 func (*FD) SetDeadline(t time.Time) error { return nil }
48
49 func (*FD) SetReadDeadline(t time.Time) error { return nil }
50
51 func (*FD) SetWriteDeadline(t time.Time) error { return nil }
52
53 // PollDescriptor returns the descriptor being used by the poller,
54 // or ^uintptr(0) if there isn't one. This is only used for testing.
55 func PollDescriptor() uintptr {
56 return ^uintptr(0)
57 }