Documentation
¶
Index ¶
- type Config
- type Reader
- type StreamBuffer
- func (s *StreamBuffer) BufferSize() uint32
- func (s *StreamBuffer) Close()
- func (s *StreamBuffer) Fd() uintptr
- func (s *StreamBuffer) HalfBufferSize() uint32
- func (s *StreamBuffer) IsBidirectional() bool
- func (s *StreamBuffer) NewReader() (io.Reader, error)
- func (s *StreamBuffer) NewWriter() (io.Writer, error)
- func (s *StreamBuffer) Path() string
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StreamBuffer ¶
type StreamBuffer struct {
// contains filtered or unexported fields
}
func New ¶
func New(config Config) (*StreamBuffer, error)
Creates a shared memory block and maps it to the current process. Returns a StreamBuffer representing the memory.
Note: See Open for details on how to use this.
func Open ¶
func Open(path string) (*StreamBuffer, error)
Maps memory pointed by path to the current process. Returns a StreamBuffer representing the memory.
Use case: You created a StreamBuffer with New, and now wants to share it with another process. So, you'd use call Open in the second process with path argument as what is returned by calling [Path] on StreamBuffer in the first process. Basically:
- In first process, call New and get StreamBuffer
- Call [Path] on that StreamBuffer and send it to the second process (using environment variable, file, etc. go figure)
- In second process, call Open with the path sent by first process.
- Now you have a structure representing the same memory in both processes. Do your thing with [NewReader] or [NewWriter]
func (*StreamBuffer) BufferSize ¶
func (s *StreamBuffer) BufferSize() uint32
func (*StreamBuffer) Close ¶
func (s *StreamBuffer) Close()
Unmaps the shared memory from the process and closes the file descriptor pointing to the memory
func (*StreamBuffer) Fd ¶
func (s *StreamBuffer) Fd() uintptr
Return the File Descriptor of the shared memory file (which is an anonymous file in our case, see manpage of memfd_create) opened by the process
func (*StreamBuffer) HalfBufferSize ¶
func (s *StreamBuffer) HalfBufferSize() uint32
func (*StreamBuffer) IsBidirectional ¶
func (s *StreamBuffer) IsBidirectional() bool
func (*StreamBuffer) Path ¶
func (s *StreamBuffer) Path() string
This function only returns correct result when being called by an instance returned by New i.e. from the process which called memfd_create