| 696 | mutex DebugFileIO::bytes_mu_(LINKER_INITIALIZED); |
| 697 | |
| 698 | bool DebugFileIO::requestDiskByteUsage(uint64 bytes) { |
| 699 | mutex_lock l(bytes_mu_); |
| 700 | if (global_disk_bytes_limit_ == 0) { |
| 701 | const char* env_tfdbg_disk_bytes_limit = getenv("TFDBG_DISK_BYTES_LIMIT"); |
| 702 | if (env_tfdbg_disk_bytes_limit == nullptr || |
| 703 | strlen(env_tfdbg_disk_bytes_limit) == 0) { |
| 704 | global_disk_bytes_limit_ = kDefaultGlobalDiskBytesLimit; |
| 705 | } else { |
| 706 | strings::safe_strtou64(string(env_tfdbg_disk_bytes_limit), |
| 707 | &global_disk_bytes_limit_); |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | if (bytes == 0) { |
| 712 | return true; |
| 713 | } |
| 714 | if (disk_bytes_used_ + bytes < global_disk_bytes_limit_) { |
| 715 | disk_bytes_used_ += bytes; |
| 716 | return true; |
| 717 | } else { |
| 718 | return false; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | void DebugFileIO::resetDiskByteUsage() { |
| 723 | mutex_lock l(bytes_mu_); |
nothing calls this directly
no test coverage detected