comparison src/lru_cache.sml @ 2298:6e580e319077

Fix condition for installing new cache entries
author Adam Chlipala <adam@chlipala.net>
date Thu, 19 Nov 2015 16:02:04 -0500
parents 6d56080f495c
children
comparison
equal deleted inserted replaced
2297:6d56080f495c 2298:6e580e319077
63 63
64 val typedArgs = paramRepeatInit (fn p => "uw_Basis_string p" ^ p) ", " 64 val typedArgs = paramRepeatInit (fn p => "uw_Basis_string p" ^ p) ", "
65 65
66 val revArgs = paramRepeatRev (fn p => "p" ^ p) ", " 66 val revArgs = paramRepeatRev (fn p => "p" ^ p) ", "
67 67
68 val argNums = List.tabulate (params, fn i => "p" ^ Int.toString i)
68 in 69 in
69 Print.box 70 Print.box
70 [string ("static uw_Sqlcache_Cache cacheStruct" ^ i ^ " = {"), 71 [string ("static uw_Sqlcache_Cache cacheStruct" ^ i ^ " = {"),
71 newline, 72 newline,
72 string " .lockIn = PTHREAD_RWLOCK_INITIALIZER,", 73 string " .lockIn = PTHREAD_RWLOCK_INITIALIZER,",
117 newline, 118 newline,
118 string " return v->result;", 119 string " return v->result;",
119 newline, 120 newline,
120 string " } else {", 121 string " } else {",
121 newline, 122 newline,
122 (*string (" puts(\"SQLCACHE: miss " ^ i ^ ".\");"), 123 (*string (" printf(\"SQLCACHE: miss " ^ i ^ " " ^ String.concatWith ", " (List.tabulate (params, fn _ => "%s")) ^ ".\\n\""),
124 (case argNums of
125 [] => Print.box []
126 | _ => Print.box [string ", ",
127 p_list string argNums]),
128 string ");",
123 newline,*) 129 newline,*)
124 string " uw_recordingStart(ctx);", 130 string " uw_recordingStart(ctx);",
125 newline, 131 newline,
126 string " return NULL;", 132 string " return NULL;",
127 newline, 133 newline,
157 newline, 163 newline,
158 string (" char *ks[] = {" ^ revArgs ^ "};"), 164 string (" char *ks[] = {" ^ revArgs ^ "};"),
159 newline, 165 newline,
160 string (" uw_Sqlcache_flush(ctx, cache" ^ i ^ ", ks);"), 166 string (" uw_Sqlcache_flush(ctx, cache" ^ i ^ ", ks);"),
161 newline, 167 newline,
168 (*string (" puts(\"SQLCACHE: flushed " ^ i ^ ".\");"),
169 newline,*)
162 string " return uw_unit_v;", 170 string " return uw_unit_v;",
163 newline, 171 newline,
164 string "}", 172 string "}",
165 newline, 173 newline,
166 newline] 174 newline]