change `hash-count' to take the lock; fix docs
This commit is contained in:
parent
9f1c2147be
commit
f3e1cf10aa
|
@ -366,10 +366,10 @@ within @scheme[proc]. @see-also-concurrency-caveat[]}
|
|||
@defproc[(hash-count [hash hash?])
|
||||
exact-nonnegative-integer?]{
|
||||
|
||||
Returns the number of keys mapped by @scheme[hash]. If @scheme[hash]
|
||||
is not created with @scheme['weak], then the result is computed in
|
||||
constant time and atomically. If @scheme[hash] is created with
|
||||
@scheme['weak], see the @concurrency-caveat[] above.}
|
||||
Returns the number of keys mapped by @scheme[hash]. Unless @scheme[hash]
|
||||
retains keys weakly, the result is computed in
|
||||
constant time and atomically. If @scheme[hash] retains it keys weakly, a
|
||||
traversal is required to count the keys.}
|
||||
|
||||
|
||||
@defproc[(hash-iterate-first [hash hash?])
|
||||
|
|
|
@ -1972,6 +1972,8 @@ static Scheme_Object *hash_table_count(int argc, Scheme_Object *argv[])
|
|||
Scheme_Bucket **buckets, *bucket;
|
||||
const char *key;
|
||||
|
||||
if (t->mutex) scheme_wait_sema(t->mutex,0);
|
||||
|
||||
buckets = t->buckets;
|
||||
weak = t->weak;
|
||||
|
||||
|
@ -1989,6 +1991,8 @@ static Scheme_Object *hash_table_count(int argc, Scheme_Object *argv[])
|
|||
SCHEME_USE_FUEL(1);
|
||||
}
|
||||
|
||||
if (t->mutex) scheme_post_sema(t->mutex);
|
||||
|
||||
return scheme_make_integer(count);
|
||||
} else {
|
||||
scheme_wrong_type("hash-count", "hash", 0, argc, argv);
|
||||
|
|
Loading…
Reference in New Issue
Block a user