I'm unable to get withCheckedThrowingContinuation to compile when there’s no return type. For example:
public
func
write(toDevice inDeviceID: Int, atAddress inAddr: Int, value inVal: Float)
async
throws
{
try await withCheckedThrowingContinuation
// ^ Generic parameter 'T' could not be inferred
{ inCont in
self.workQ.async
{
do
{
self.deviceID = inDeviceID
try self.write(address: inAddr, value: inVal)
inCont.resume()
}
catch (let e)
{
inCont.resume(throwing: e)
}
}
}
}
A version that returns works just fine:
public
func
readRegister(address inAddr: Int, fromDevice inDeviceID: Int)
async
throws
-> UInt16
{
try await withCheckedThrowingContinuation
{ inCont in
self.workQ.async
{
do
{
self.deviceID = inDeviceID
let r = try self.readRegister(address: inAddr)
inCont.resume(returning: r)
}
catch (let e)
{
inCont.resume(throwing: e)
}
}
}
}