Sets the value or error to the promise.
The ownership of the value or error is transferred to the promise, therefore this result should not be used after this method called.