File: Types.hs

package info (click to toggle)
haskell-recv 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72 kB
  • sloc: haskell: 170; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 762 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
29
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