{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EC2.Types.CpuOptions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.CpuOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | The CPU options for the instance.
--
-- /See:/ 'newCpuOptions' smart constructor.
data CpuOptions = CpuOptions'
  { -- | The number of CPU cores for the instance.
    CpuOptions -> Maybe Int
coreCount :: Prelude.Maybe Prelude.Int,
    -- | The number of threads per CPU core.
    CpuOptions -> Maybe Int
threadsPerCore :: Prelude.Maybe Prelude.Int
  }
  deriving (CpuOptions -> CpuOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CpuOptions -> CpuOptions -> Bool
$c/= :: CpuOptions -> CpuOptions -> Bool
== :: CpuOptions -> CpuOptions -> Bool
$c== :: CpuOptions -> CpuOptions -> Bool
Prelude.Eq, ReadPrec [CpuOptions]
ReadPrec CpuOptions
Int -> ReadS CpuOptions
ReadS [CpuOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CpuOptions]
$creadListPrec :: ReadPrec [CpuOptions]
readPrec :: ReadPrec CpuOptions
$creadPrec :: ReadPrec CpuOptions
readList :: ReadS [CpuOptions]
$creadList :: ReadS [CpuOptions]
readsPrec :: Int -> ReadS CpuOptions
$creadsPrec :: Int -> ReadS CpuOptions
Prelude.Read, Int -> CpuOptions -> ShowS
[CpuOptions] -> ShowS
CpuOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CpuOptions] -> ShowS
$cshowList :: [CpuOptions] -> ShowS
show :: CpuOptions -> String
$cshow :: CpuOptions -> String
showsPrec :: Int -> CpuOptions -> ShowS
$cshowsPrec :: Int -> CpuOptions -> ShowS
Prelude.Show, forall x. Rep CpuOptions x -> CpuOptions
forall x. CpuOptions -> Rep CpuOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CpuOptions x -> CpuOptions
$cfrom :: forall x. CpuOptions -> Rep CpuOptions x
Prelude.Generic)

-- |
-- Create a value of 'CpuOptions' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'coreCount', 'cpuOptions_coreCount' - The number of CPU cores for the instance.
--
-- 'threadsPerCore', 'cpuOptions_threadsPerCore' - The number of threads per CPU core.
newCpuOptions ::
  CpuOptions
newCpuOptions :: CpuOptions
newCpuOptions =
  CpuOptions'
    { $sel:coreCount:CpuOptions' :: Maybe Int
coreCount = forall a. Maybe a
Prelude.Nothing,
      $sel:threadsPerCore:CpuOptions' :: Maybe Int
threadsPerCore = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of CPU cores for the instance.
cpuOptions_coreCount :: Lens.Lens' CpuOptions (Prelude.Maybe Prelude.Int)
cpuOptions_coreCount :: Lens' CpuOptions (Maybe Int)
cpuOptions_coreCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CpuOptions' {Maybe Int
coreCount :: Maybe Int
$sel:coreCount:CpuOptions' :: CpuOptions -> Maybe Int
coreCount} -> Maybe Int
coreCount) (\s :: CpuOptions
s@CpuOptions' {} Maybe Int
a -> CpuOptions
s {$sel:coreCount:CpuOptions' :: Maybe Int
coreCount = Maybe Int
a} :: CpuOptions)

-- | The number of threads per CPU core.
cpuOptions_threadsPerCore :: Lens.Lens' CpuOptions (Prelude.Maybe Prelude.Int)
cpuOptions_threadsPerCore :: Lens' CpuOptions (Maybe Int)
cpuOptions_threadsPerCore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
$sel:threadsPerCore:CpuOptions' :: CpuOptions -> Maybe Int
threadsPerCore} -> Maybe Int
threadsPerCore) (\s :: CpuOptions
s@CpuOptions' {} Maybe Int
a -> CpuOptions
s {$sel:threadsPerCore:CpuOptions' :: Maybe Int
threadsPerCore = Maybe Int
a} :: CpuOptions)

instance Data.FromXML CpuOptions where
  parseXML :: [Node] -> Either String CpuOptions
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> CpuOptions
CpuOptions'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"coreCount")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"threadsPerCore")

instance Prelude.Hashable CpuOptions where
  hashWithSalt :: Int -> CpuOptions -> Int
hashWithSalt Int
_salt CpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:CpuOptions' :: CpuOptions -> Maybe Int
$sel:coreCount:CpuOptions' :: CpuOptions -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
coreCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
threadsPerCore

instance Prelude.NFData CpuOptions where
  rnf :: CpuOptions -> ()
rnf CpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:CpuOptions' :: CpuOptions -> Maybe Int
$sel:coreCount:CpuOptions' :: CpuOptions -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
coreCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
threadsPerCore