| 1356 | | static void |
| 1357 | | notify_sync(int32 transactionID, int32 event, void *_cache) |
| 1358 | | { |
| 1359 | | block_cache *cache = (block_cache *)_cache; |
| 1360 | | |
| 1361 | | cache->condition_variable.NotifyOne(); |
| 1362 | | } |
| 1363 | | |
| 1364 | | |
| 1365 | | static void |
| 1366 | | wait_for_notifications(block_cache *cache) |
| 1367 | | { |
| 1368 | | // add sync notification |
| 1369 | | cache_notification notification; |
| 1370 | | set_notification(NULL, notification, TRANSACTION_WRITTEN, notify_sync, |
| 1371 | | cache); |
| 1372 | | |
| 1373 | | ConditionVariableEntry<block_cache> entry; |
| 1374 | | entry.Add(cache); |
| 1375 | | |
| 1376 | | add_notification(cache, ¬ification, TRANSACTION_WRITTEN, false); |
| 1377 | | |
| 1378 | | // wait for notification hook to be called |
| 1379 | | entry.Wait(); |
| 1380 | | } |
| 1381 | | |
| 1382 | | |
| | 1536 | static void |
| | 1537 | notify_sync(int32 transactionID, int32 event, void *_cache) |
| | 1538 | { |
| | 1539 | block_cache *cache = (block_cache *)_cache; |
| | 1540 | |
| | 1541 | cache->condition_variable.NotifyOne(); |
| | 1542 | } |
| | 1543 | |
| | 1544 | |
| | 1545 | static void |
| | 1546 | wait_for_notifications(block_cache *cache) |
| | 1547 | { |
| | 1548 | if (find_thread(NULL) == sWriterNotifyThread) { |
| | 1549 | // We're the notifier thread, don't wait, but flush all pending |
| | 1550 | // notifications directly. |
| | 1551 | flush_pending_notifications(cache); |
| | 1552 | return; |
| | 1553 | } |
| | 1554 | |
| | 1555 | // add sync notification |
| | 1556 | cache_notification notification; |
| | 1557 | set_notification(NULL, notification, TRANSACTION_WRITTEN, notify_sync, |
| | 1558 | cache); |
| | 1559 | |
| | 1560 | ConditionVariableEntry<block_cache> entry; |
| | 1561 | entry.Add(cache); |
| | 1562 | |
| | 1563 | add_notification(cache, ¬ification, TRANSACTION_WRITTEN, false); |
| | 1564 | |
| | 1565 | // wait for notification hook to be called |
| | 1566 | entry.Wait(); |
| | 1567 | } |
| | 1568 | |
| | 1569 | |