aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file-cache.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-03-18 15:02:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-03-18 15:02:39 +0200
commit6b9bdad3b68b12ff8e2075d54c1f7f005bb2f768 (patch)
tree8ccd47c832ea6fd8dea6d12e3b9f36c8c0e72033 /libbuild2/file-cache.ixx
parent562af3a7f3742bf57b007e904e0bb661a5da1dab (diff)
Add noop mode to file cache, add --file-cache option to select
Diffstat (limited to 'libbuild2/file-cache.ixx')
-rw-r--r--libbuild2/file-cache.ixx19
1 files changed, 12 insertions, 7 deletions
diff --git a/libbuild2/file-cache.ixx b/libbuild2/file-cache.ixx
index 2b76fb6..1a01410 100644
--- a/libbuild2/file-cache.ixx
+++ b/libbuild2/file-cache.ixx
@@ -95,7 +95,9 @@ namespace build2
inline void file_cache::entry::
unpin ()
{
- if (--pin_ == 0 && (state_ == uncomp || state_ == decomp))
+ if (--pin_ == 0 &&
+ !comp_path_.empty () &&
+ (state_ == uncomp || state_ == decomp))
preempt ();
}
@@ -106,11 +108,11 @@ namespace build2
}
inline file_cache::entry::
- entry (path_type p, bool t)
+ entry (path_type p, bool t, bool c)
: temporary (t),
state_ (uninit),
path_ (move (p)),
- comp_path_ (path_ + ".lz4"),
+ comp_path_ (c ? path_ + ".lz4" : path_type ()),
pin_ (1)
{
}
@@ -152,13 +154,13 @@ namespace build2
inline file_cache::entry file_cache::
create (path f, optional<bool>)
{
- return entry (move (f), true /* temporary */);
+ return entry (move (f), true /* temporary */, compress_);
}
inline file_cache::entry file_cache::
create_existing (path f)
{
- entry e (move (f), false /* temporary */);
+ entry e (move (f), false /* temporary */, compress_);
e.init_existing ();
return e;
}
@@ -166,11 +168,14 @@ namespace build2
inline string file_cache::
compressed_extension (const char* e)
{
- return (e != nullptr ? string (e) : string ()) + ".lz4";
+ return compress_
+ ? (e != nullptr ? string (e) : string ()) + ".lz4"
+ : string ();
}
inline file_cache::
- file_cache (scheduler&)
+ file_cache (bool compress)
+ : compress_ (compress)
{
}
}