File: Types.hs

package info (click to toggle)
haskell-recv 0.1.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 76 kB
  • sloc: haskell: 208; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Network.Socket.BufferPool.Types where

import Data.ByteString (ByteString)
import Data.IORef
import Data.Word (Word8)
import Foreign.Ptr (Ptr)

-- | Type for buffer.
type Buffer = Ptr Word8

-- | Type for buffer size.
type BufSize = Int

-- | Type for read buffer pool.
data BufferPool = BufferPool {
    minBufSize :: Int -- ^ If the buffer is larger than or equal to this size,
                      --   the buffer is used.
                      --   Otherwise, a new buffer is allocated.
                      --   The thrown buffer is eventually freed.
  , maxBufSize :: Int
  , poolBuffer :: IORef ByteString
  }

-- | Type for the receiving function with a buffer pool.
type Recv = IO ByteString

-- | Type for the receiving function which receives N bytes.
type RecvN = Int -> IO ByteString