diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
commit | 503f176e001ddf15e6e32bc912cf10b5764bc23b (patch) | |
tree | 2595bc45e582df3ede9241c00656b65866301e38 /src/common | |
parent | 0934f9943ef7bdec8c2eee3ea31b5e0f1e8a3faf (diff) | |
download | kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.tar.gz kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.zip |
Process exiting & thread termination. IMPORTANT NOTE FOLLOWS.
Threads may now communicate via wait_on(void* ressource) and resume_on (void* ressource).
Previous pause() is replaced by wait_on(current_thread) and resume(thread) by resume_on(thread).
wait_on(x) may return false, indicating that the reason for returning is NOT that resume_on(x)
was called but something else happenned. Typically false indicates that the curent thread
is being killed and must terminate its kernel-land processing as soon as possible.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/include/hashtbl.h | 5 | ||||
-rw-r--r-- | src/common/libalgo/hashtbl.c | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/common/include/hashtbl.h b/src/common/include/hashtbl.h index 818cfa0..b9c7178 100644 --- a/src/common/include/hashtbl.h +++ b/src/common/include/hashtbl.h @@ -25,6 +25,11 @@ void hashtbl_remove(hashtbl_t* ht, const void* key); void* hashtbl_find(hashtbl_t* ht, const void* key); // null when not found void hashtbl_iter(hashtbl_t* ht, kv_iter_fun_t f); +// hashtbl_change is particular : +// - it does NOT call malloc and uses the existing hashtbl cell +// - it does NOT call the on_release fun on the previous element +bool hashtbl_change(hashtbl_t* ht, void* key, void* v); + size_t hashtbl_count(hashtbl_t* ht); /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/libalgo/hashtbl.c b/src/common/libalgo/hashtbl.c index f490632..f34c6d4 100644 --- a/src/common/libalgo/hashtbl.c +++ b/src/common/libalgo/hashtbl.c @@ -160,4 +160,17 @@ size_t hashtbl_count(hashtbl_t* ht) { return ht->nitems; } +bool hashtbl_change(hashtbl_t* ht, void* key, void* newval) { + size_t slot = SLOT_OF_HASH(ht->hf(key), ht->size); + + for (hashtbl_item_t *i = ht->items[slot]; i != 0; i = i->next) { + if (ht->ef(i->key, key)) { + i->val = newval; + return true; + } + } + + return false; +} + /* vim: set ts=4 sw=4 tw=0 noet :*/ |