#net/pool
Xu 0.16.0 API
import: #net/pool
counts: 1 functions, 4 methods, 2 types, 0 constants, 0 method sets
The state channel serializes lifecycle changes, not network dialing/I/O.
struct State
pub struct State {
pub closed int
pub idle []int
pub borrowed map[int]bool
}
Purpose
The state channel serializes lifecycle changes, not network dialing/I/O.
Public fields
closed int- field (int)
idle []int- field ([]int)
borrowed map[int]bool- field (map[int]bool)
struct SocketPool
pub struct SocketPool {
pub state chan State
pub max_idle int
}
Purpose
Pool Connection pool manager scheduling reusable socket connections.
Public fields
state chan State- field (channel; type chan State)
max_idle int- field (int)
new_state
pub fn new_state() chan State
Purpose
Construct state.
Parameters
No arguments are required.
Returns
chan State — a value of this type
(&SocketPool) take
pub fn (p &SocketPool) take() int
Purpose
1 means dial a new socket; -2 means the pool is closed.
Parameters
p &SocketPool- The
SocketPool instance used by this call (borrow).
Returns
int — a value of this type
(&SocketPool) adopt
pub fn (p &SocketPool) adopt(fd int) bool
Purpose
A close concurrent with an outstanding dial wins; the new fd is closed.
Parameters
p &SocketPool- The
SocketPool instance used by this call (borrow).
fd int- file descriptor (int)
Returns
bool — true or false
(&SocketPool) release
pub fn (p &SocketPool) release(fd int, reusable bool)
Purpose
max_idle limits retained sockets, not the total number of open sockets. Borrowers must return/discard each fd exactly once, before borrowing again.
Parameters
p &SocketPool- The
SocketPool instance used by this call (borrow).
fd int- file descriptor (int)
reusable bool- reusable (bool)
Returns
This call does not return a value.
(&SocketPool) close
pub fn (p &SocketPool) close()
Purpose
Operation on &SocketPool: close the resource.
Parameters
p &SocketPool- The
SocketPool instance used by this call (borrow).
Returns
This call does not return a value.