<commit_before>{-# OPTIONS_GHC -fno-warn-orphans #-}
{-|
Module      : Game.GoreAndAsh.Network.Options
Description : Module creation options
Copyright   : (c) <NAME>, 2015-2016
License     : BSD3
Maintainer  : <EMAIL>
Stability   : experimental
Portability : POSIX
-}
module Game.GoreAndAsh.Network.Options(
    NetworkOptions
  , defaultNetworkOptions
  , networkChannelsCount
  , networkIncomingBandwidth
  , networkOutcomingBandwidth
  , networkDetailedLogging
  , networkPollTimeout
  , networkNextOptions
  ) where

import Control.DeepSeq
import Data.Word
import GHC.Generics

-- | Configuration of network module
data NetworkOptions s = NetworkOptions {
    networkChannelsCount      :: !Word -- ^ Number of channels to open
  , networkIncomingBandwidth  :: !Word32 -- ^ Incoming max bandwidth
  , networkOutcomingBandwidth :: !Word32 -- ^ Outcoming max bandwidth
  , networkDetailedLogging    :: !Bool -- ^ Should log everything or not
  -- | Maximum time that polling can await an message (milliseconds).
  --
  -- Note: we use a safe call to get next event from enet library, so
  -- one call cost around 100ns. Also network packages are sent each call
  -- to the function, so the parameter should have reasonable small value,
  -- but not too small or you will get high CPU usage on idle run.
  --
  -- If set to zero, the implementation would use unsafe call to get next
  -- event from enet library with no timeout. So it is would lead to high
  -- CPU usage at idle.
  , networkPollTimeout        :: !Word32
  , networkNextOptions        :: !s -- ^ Options of underlying module
  }
  deriving (Generic)

instance NFData s => NFData (NetworkOptions s)

-- | Default values for client configuration of network module
--
-- @
-- NetworkOptions {
-- , networkChannelsCount = 2
-- , networkIncomingBandwidth = 0
-- , networkOutcomingBandwidth = 0
-- , networkDetailedLogging = False
-- , networkPollTimeout = 100
-- , networkNextOptions = s
-- }
-- @
defaultNetworkOptions :: s -- ^ Options of underlying module
  -> NetworkOptions s
defaultNetworkOptions s = NetworkOptions {
    networkChannelsCount = 2
  , networkIncomingBandwidth = 0
  , networkOutcomingBandwidth = 0
  , networkDetailedLogging = False<commit_msg>Set default count of channels to 3 for sync module needs<commit_after>{-# OPTIONS_GHC -fno-warn-orphans #-}
{-|
Module      : Game.GoreAndAsh.Network.Options
Description : Module creation options
Copyright   : (c) <NAME>, 2015-2016
License     : BSD3
Maintainer  : <EMAIL>
Stability   : experimental
Portability : POSIX
-}
module Game.GoreAndAsh.Network.Options(
    NetworkOptions
  , defaultNetworkOptions
  , networkChannelsCount
  , networkIncomingBandwidth
  , networkOutcomingBandwidth
  , networkDetailedLogging
  , networkPollTimeout
  , networkNextOptions
  ) where

import Control.DeepSeq
import Data.Word
import GHC.Generics

-- | Configuration of network module
data NetworkOptions s = NetworkOptions {
    networkChannelsCount      :: !Word -- ^ Number of channels to open
  , networkIncomingBandwidth  :: !Word32 -- ^ Incoming max bandwidth
  , networkOutcomingBandwidth :: !Word32 -- ^ Outcoming max bandwidth
  , networkDetailedLogging    :: !Bool -- ^ Should log everything or not
  -- | Maximum time that polling can await an message (milliseconds).
  --
  -- Note: we use a safe call to get next event from enet library, so
  -- one call cost around 100ns. Also network packages are sent each call
  -- to the function, so the parameter should have reasonable small value,
  -- but not too small or you will get high CPU usage on idle run.
  --
  -- If set to zero, the implementation would use unsafe call to get next
  -- event from enet library with no timeout. So it is would lead to high
  -- CPU usage at idle.
  , networkPollTimeout        :: !Word32
  , networkNextOptions        :: !s -- ^ Options of underlying module
  }
  deriving (Generic)

instance NFData s => NFData (NetworkOptions s)

-- | Default values for client configuration of network module
--
-- @
-- NetworkOptions {
-- , networkChannelsCount = 3
-- , networkIncomingBandwidth = 0
-- , networkOutcomingBandwidth = 0
-- , networkDetailedLogging = False
-- , networkPollTimeout = 100
-- , networkNextOptions = s
-- }
-- @
defaultNetworkOptions :: s -- ^ Options of underlying module
  -> NetworkOptions s
defaultNetworkOptions s = NetworkOptions {
    networkChannelsCount = 3
  , networkIncomingBandwidth = 0
  , networkOutcomingBandwidth = 0
  , networkDetailedLogging = False
{'fraction_non_alphanumeric': 0.08446321404756613, 'fraction_numerical': 0.012224938875305624, 'mean_word_length': 3.398826979472141, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7472188', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1232, 'n_words': 443}