Skip to content

Commit 19953e1

Browse files
committed
Improve representation of ProcessId
(Use UNPACK where appropriate)
1 parent de2aaca commit 19953e1

File tree

1 file changed

+7
-11
lines changed
  • distributed-process/src/Control/Distributed/Process/Internal

1 file changed

+7
-11
lines changed

distributed-process/src/Control/Distributed/Process/Internal/Types.hs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,17 @@ import Control.Distributed.Static (RemoteTable, Closure)
105105
--------------------------------------------------------------------------------
106106

107107
-- | Node identifier
108-
data NodeId = NodeId { nodeAddress :: !(NT.EndPointAddress) }
109-
deriving (Eq, Ord)
110-
111-
instance Binary NodeId where
112-
put (NodeId nid) = put nid
113-
get = NodeId <$> get
108+
newtype NodeId = NodeId { nodeAddress :: NT.EndPointAddress }
109+
deriving (Eq, Ord, Binary)
114110

115111
instance Show NodeId where
116112
show (NodeId addr) = "nid://" ++ show addr
117113

118114
-- | A local process ID consists of a seed which distinguishes processes from
119115
-- different instances of the same local node and a counter
120116
data LocalProcessId = LocalProcessId
121-
{ lpidUnique :: !Int32
122-
, lpidCounter :: !Int32
117+
{ lpidUnique :: {-# UNPACK #-} !Int32
118+
, lpidCounter :: {-# UNPACK #-} !Int32
123119
}
124120
deriving (Eq, Ord, Typeable, Show)
125121

@@ -128,7 +124,7 @@ data ProcessId = ProcessId
128124
{ -- | The ID of the node the process is running on
129125
processNodeId :: !NodeId
130126
-- | Node-local identifier for the process
131-
, processLocalId :: !LocalProcessId
127+
, processLocalId :: {-# UNPACK #-} !LocalProcessId
132128
}
133129
deriving (Eq, Ord, Typeable)
134130

@@ -219,9 +215,9 @@ type LocalSendPortId = Int32
219215
-- to create a SendPort.
220216
data SendPortId = SendPortId {
221217
-- | The ID of the process that will receive messages sent on this port
222-
sendPortProcessId :: !ProcessId
218+
sendPortProcessId :: {-# UNPACK #-} !ProcessId
223219
-- | Process-local ID of the channel
224-
, sendPortLocalId :: !LocalSendPortId
220+
, sendPortLocalId :: {-# UNPACK #-} !LocalSendPortId
225221
}
226222
deriving (Eq, Ord)
227223

0 commit comments

Comments
 (0)