better. most probably fix rpc lock issue

This commit is contained in:
voidlizard 2025-02-15 14:00:29 +03:00
parent 8ca4dd79bf
commit 3e4762d880
1 changed files with 1 additions and 10 deletions

View File

@ -121,22 +121,13 @@ makeRequest rnum input = ServiceRequest rnum (serialise (fromIntegral idx :: Int
where where
idx = findMethodIndex @method @api idx = findMethodIndex @method @api
rnumnum :: TVar Word64
rnumnum = unsafePerformIO (newTVarIO 1)
{-# NOINLINE rnumnum #-}
makeRequestR :: forall api method e m . ( KnownNat (FromJust (FindMethodIndex 0 method api)) makeRequestR :: forall api method e m . ( KnownNat (FromJust (FindMethodIndex 0 method api))
, Serialise (Input method) , Serialise (Input method)
, MonadIO m , MonadIO m
) )
=> Input method -> m (ServiceProto api e) => Input method -> m (ServiceProto api e)
makeRequestR input = do makeRequestR input = do
n <- liftIO $ randomIO @Word64 rnum <- liftIO $ randomIO @Word64
rnum <- atomically do
n <- readTVar rnumnum
modifyTVar' rnumnum succ
pure (fromIntegral n)
pure $ ServiceRequest rnum (serialise (fromIntegral idx :: Int, serialise input)) pure $ ServiceRequest rnum (serialise (fromIntegral idx :: Int, serialise input))
where where
idx = findMethodIndex @method @api idx = findMethodIndex @method @api