Created
March 31, 2015 17:53
-
-
Save qix/f0e3ecb18e4183978850 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?hh | |
function printResult($result) { | |
var_dump($result->vectorRowsTyped()); | |
} | |
async function genMain() { | |
$conn = await AsyncMysqlClient::connect( | |
'127.0.0.1', | |
3306, | |
'authbox', | |
'root', | |
'', | |
); | |
$queries = []; | |
for ($i = 0; $i < 1000; $i++) { | |
$queries[] = "SELECT 1"; | |
} | |
// Yay instant: | |
$results = await $conn->multiQuery($queries); | |
array_map(printResult, $results); | |
$a = $conn->query($queries[0]); | |
sleep(0.01); | |
// Throws "Fatal error: Uncaught exception 'InvalidArgumentException' with message 'attempt to invoke method on a busy connection'" | |
$b = $conn->query($queries[1]); | |
$result = await $a; | |
printResult($result); | |
$result = await $b; | |
printResult($result); | |
} | |
genMain()->join(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment