question about Synchronous API
Closed this issue · 1 comments
calvin2021y commented
Synchronous API will block os native thread ?
Or it only block erlang actor, the os native thread will use a event loop to handle io ?
silviucpp commented
No API is blocking the native thread. The SYNC API will only block the erlang actor.
If you look to the code:
query(Q) ->
case query_async(Q) of
{ok, Tag} ->
receive_response(Tag);
Error ->
Error
end.
It will send the query message async and then wait for the response. The wait will block only the erlang calling process.
receive_response(Tag) ->
receive
{execute_statement_result, Tag, Result} ->
Result
after ?RESPONSE_TIMEOUT ->
{error, timeout}
end.
Silviu