| 851 | void DeleteRandom(ThreadState* thread) { DoDelete(thread, false); } |
| 852 | |
| 853 | void ReadWhileWriting(ThreadState* thread) { |
| 854 | if (thread->tid > 0) { |
| 855 | ReadRandom(thread); |
| 856 | } else { |
| 857 | // Special thread that keeps writing until other threads are done. |
| 858 | RandomGenerator gen; |
| 859 | while (true) { |
| 860 | { |
| 861 | MutexLock l(&thread->shared->mu); |
| 862 | if (thread->shared->num_done + 1 >= thread->shared->num_initialized) { |
| 863 | // Other threads have finished |
| 864 | break; |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | const int k = thread->rand.Next() % FLAGS_num; |
| 869 | char key[100]; |
| 870 | snprintf(key, sizeof(key), "%016d", k); |
| 871 | Status s = db_->Put(write_options_, key, gen.Generate(value_size_)); |
| 872 | if (!s.ok()) { |
| 873 | fprintf(stderr, "put error: %s\n", s.ToString().c_str()); |
| 874 | exit(1); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | // Do not count any of the preceding work/delay in stats. |
| 879 | thread->stats.Start(); |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | void Compact(ThreadState* thread) { db_->CompactRange(nullptr, nullptr); } |
| 884 | |