Created
March 20, 2017 19:07
-
-
Save portante/b80c815efd3b319f206cd939c63eec10 to your computer and use it in GitHub Desktop.
An example code flow for seeding
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
| seeded_state = UNSEEDED; | |
| lock = Lock(); | |
| syncing = Sync(); | |
| process() { | |
| if (seeded_state == SEEDED) { | |
| continue; | |
| } else { | |
| lock.lock(); | |
| try { | |
| if (seeded_state == UNSEEDED) { | |
| seeded_state = SEEDING; | |
| lock.unlock(); | |
| seed_searchguard(); | |
| lock.lock(); | |
| seeded_state = SEEDED; | |
| syncing.signalAll(); | |
| } | |
| else { | |
| while (seeded_state != SEEDED) { | |
| syncing.await(TIMEOUT); | |
| } | |
| } | |
| } | |
| finally { | |
| lock.unlock(); | |
| } | |
| } | |
| assert seeded_state == SEEDED; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment