diff --git a/configure b/configure index 464cade..f4df79d 100755 --- a/configure +++ b/configure @@ -33,7 +33,7 @@ EXIT_FAILURE=1 P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.2.17'} +VERSION=${VERSION:-'0.2.18'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} diff --git a/doc/Makefile.in b/doc/Makefile.in index b67dfc8..397f883 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -17,6 +17,7 @@ OBJECTS=ck_ht_count \ ck_ht_put_spmc \ ck_ht_remove_spmc \ ck_ht_reset_spmc \ + ck_ht_reset_size_spmc \ ck_ht_set_spmc \ ck_ht_entry_empty \ ck_ht_entry_key \ @@ -50,6 +51,7 @@ OBJECTS=ck_ht_count \ ck_epoch_poll \ ck_epoch_recycle \ ck_epoch_register \ + ck_epoch_reclaim \ ck_epoch_synchronize \ ck_epoch_unregister \ ck_bag_allocator_set \ @@ -76,6 +78,7 @@ OBJECTS=ck_ht_count \ ck_hs_grow \ ck_hs_count \ ck_hs_reset \ + ck_hs_reset_size \ ck_hs_stat \ ck_cohort \ CK_COHORT_PROTOTYPE \ @@ -116,7 +119,9 @@ OBJECTS=ck_ht_count \ ck_ring_trydequeue_spmc \ ck_ring_dequeue_spsc \ ck_ring_enqueue_spsc \ - ck_ring_enqueue_spsc_size + ck_ring_enqueue_spsc_size \ + ck_ring_size \ + ck_ring_capacity all: for target in $(OBJECTS); do \ diff --git a/doc/ck_epoch_barrier b/doc/ck_epoch_barrier index e4b63ac..80cc70e 100644 --- a/doc/ck_epoch_barrier +++ b/doc/ck_epoch_barrier @@ -112,6 +112,7 @@ must have been previously registered via .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , .Xr ck_epoch_end 3 diff --git a/doc/ck_epoch_begin b/doc/ck_epoch_begin index 44ed804..6a71860 100644 --- a/doc/ck_epoch_begin +++ b/doc/ck_epoch_begin @@ -63,6 +63,7 @@ must have been previously registered via .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_end 3 diff --git a/doc/ck_epoch_call b/doc/ck_epoch_call index 2736488..e3aeefb 100644 --- a/doc/ck_epoch_call +++ b/doc/ck_epoch_call @@ -48,7 +48,7 @@ The function will be provided the pointer specified by .Fa entry . The function will execute at some time in the future via calls to -.Fn ck_epoch_synchronize 3 , +.Fn ck_epoch_reclaim 3 , .Fn ck_epoch_barrier 3 or .Fn ck_epoch_poll 3 . @@ -127,6 +127,7 @@ must have been previously registered via .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_begin 3 , .Xr ck_epoch_end 3 diff --git a/doc/ck_epoch_end b/doc/ck_epoch_end index 69cb1eb..eea2dad 100644 --- a/doc/ck_epoch_end +++ b/doc/ck_epoch_end @@ -57,6 +57,7 @@ must have been previously registered via .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 diff --git a/doc/ck_epoch_init b/doc/ck_epoch_init index 1d39292..e22294d 100644 --- a/doc/ck_epoch_init +++ b/doc/ck_epoch_init @@ -60,6 +60,7 @@ object. .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_epoch_poll b/doc/ck_epoch_poll index 4dd57c3..b80c42e 100644 --- a/doc/ck_epoch_poll +++ b/doc/ck_epoch_poll @@ -64,6 +64,7 @@ must have been previously registered via .Xr ck_epoch_unregister 3 , .Xr ck_epoch_recycle 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_epoch_reclaim b/doc/ck_epoch_reclaim new file mode 100644 index 0000000..ffe3bac --- /dev/null +++ b/doc/ck_epoch_reclaim @@ -0,0 +1,92 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 2, 2013 +.Dt CK_EPOCH_RECLAIM 3 +.Sh NAME +.Nm ck_epoch_reclaim +.Nd immediately execute all deferred callbacks +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_epoch.h +.Ft void +.Fn ck_epoch_reclaim "ck_epoch_record_t *record" +.Sh DESCRIPTION +The +.Fn ck_epoch_reclaim 3 +function will unconditionally execute all callbacks +that have been deferred with +.Fn ck_epoch_call 3 . +.Sh EXAMPLE +.Bd -literal -offset indent + +#include +#include +#include + +/* + * epoch was previously initialized with ck_epoch_init. + */ +ck_epoch_t *epoch; + +void +function(void) +{ + ck_epoch_record_t *record; + + logically_delete(object); + ck_epoch_call(epoch, record, &object->epoch_entry, destructor); + + /* + * Wait until no threads could possibly have a reference to the + * object we just deleted. + */ + ck_epoch_synchronize(epoch, record); + + /* + * Execute all deferred callbacks. + */ + ck_epoch_reclaim(record); + + return; +} +.Ed +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_epoch_init 3 , +.Xr ck_epoch_register 3 , +.Xr ck_epoch_unregister 3 , +.Xr ck_epoch_recycle 3 , +.Xr ck_epoch_poll 3 , +.Xr ck_epoch_reclaim 3 , +.Xr ck_epoch_barrier 3 , +.Xr ck_epoch_call 3 , +.Xr ck_epoch_begin 3 , +.Xr ck_epoch_end 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_recycle b/doc/ck_epoch_recycle index b7fce30..530079c 100644 --- a/doc/ck_epoch_recycle +++ b/doc/ck_epoch_recycle @@ -93,6 +93,7 @@ is not a valid epoch object. .Xr ck_epoch_unregister 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_epoch_register b/doc/ck_epoch_register index 268e874..85ea461 100644 --- a/doc/ck_epoch_register +++ b/doc/ck_epoch_register @@ -58,6 +58,7 @@ This function has no return value. .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_epoch_synchronize b/doc/ck_epoch_synchronize index e1b8ab3..33df67c 100644 --- a/doc/ck_epoch_synchronize +++ b/doc/ck_epoch_synchronize @@ -42,15 +42,14 @@ function will block the caller until a grace period has been detected, according to the semantics of epoch reclamation. Any objects requiring safe memory reclamation which are logically deleted are safe for physical deletion following a call to -.Fn ck_epoch_synchronize 3 . This function may also dispatch callbacks -associated with -.Fa epoch -that were previously scheduled via -.Fn ck_epoch_call 3 . +.Fn ck_epoch_synchronize 3 . If you require that all callbacks be dispatched, then it is suggested that you use .Fn ck_epoch_barrier 3 -instead. +instead or follow a call of +.Fn ck_epoch_synchronize 3 +with +.Fn ck_epoch_reclaim 3 . .Sh EXAMPLE .Bd -literal -offset indent @@ -115,6 +114,7 @@ must have been previously registered via .Xr ck_epoch_unregister 3 , .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_epoch_unregister b/doc/ck_epoch_unregister index 7976571..9f297ee 100644 --- a/doc/ck_epoch_unregister +++ b/doc/ck_epoch_unregister @@ -64,6 +64,7 @@ function. .Xr ck_epoch_recycle 3 , .Xr ck_epoch_poll 3 , .Xr ck_epoch_synchronize 3 , +.Xr ck_epoch_reclaim 3 , .Xr ck_epoch_barrier 3 , .Xr ck_epoch_call 3 , .Xr ck_epoch_begin 3 , diff --git a/doc/ck_hs_count b/doc/ck_hs_count index a356a3a..dba8597 100644 --- a/doc/ck_hs_count +++ b/doc/ck_hs_count @@ -59,6 +59,7 @@ thread. .Xr ck_hs_remove 3 , .Xr ck_hs_grow 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_destroy b/doc/ck_hs_destroy index 33d1f70..2d3b255 100644 --- a/doc/ck_hs_destroy +++ b/doc/ck_hs_destroy @@ -66,6 +66,7 @@ This function is guaranteed not to fail. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_get b/doc/ck_hs_get index 16f07d3..d4986e2 100644 --- a/doc/ck_hs_get +++ b/doc/ck_hs_get @@ -77,6 +77,7 @@ are uninitialized. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_grow b/doc/ck_hs_grow index a1e1241..efd41e4 100644 --- a/doc/ck_hs_grow +++ b/doc/ck_hs_grow @@ -70,6 +70,7 @@ failures. .Xr ck_hs_remove 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_init b/doc/ck_hs_init index 78b735b..86bb02a 100644 --- a/doc/ck_hs_init +++ b/doc/ck_hs_init @@ -148,6 +148,7 @@ object. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_iterator_init b/doc/ck_hs_iterator_init index 5fe2d42..bcd620f 100644 --- a/doc/ck_hs_iterator_init +++ b/doc/ck_hs_iterator_init @@ -67,6 +67,7 @@ This function will not fail. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_next b/doc/ck_hs_next index d93b8c4..8db8bfe 100644 --- a/doc/ck_hs_next +++ b/doc/ck_hs_next @@ -81,6 +81,7 @@ are uninitialized. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_put b/doc/ck_hs_put index da6cc32..eada77b 100644 --- a/doc/ck_hs_put +++ b/doc/ck_hs_put @@ -87,6 +87,7 @@ to accomodate key insertion. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_remove b/doc/ck_hs_remove index 89d3035..653808c 100644 --- a/doc/ck_hs_remove +++ b/doc/ck_hs_remove @@ -81,6 +81,7 @@ are uninitialized. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_reset b/doc/ck_hs_reset index c241b9a..86eeec5 100644 --- a/doc/ck_hs_reset +++ b/doc/ck_hs_reset @@ -64,6 +64,7 @@ thread. .Xr ck_hs_put 3 , .Xr ck_hs_set 3 , .Xr ck_hs_remove 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_stat 3 diff --git a/doc/ck_hs_reset_size b/doc/ck_hs_reset_size new file mode 100644 index 0000000..caf1348 --- /dev/null +++ b/doc/ck_hs_reset_size @@ -0,0 +1,75 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 5, 2013 +.Dt CK_HS_RESET_SIZE 3 +.Sh NAME +.Nm ck_hs_reset_size +.Nd remove all keys from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_hs.h +.Ft bool +.Fn ck_hs_reset_size "ck_hs_t *hs" "unsigned long size" +.Sh DESCRIPTION +The +.Fn ck_hs_reset_size 3 +function will remove all keys stored in the hash +set pointed to by the +.Fa hs +argument and create a new generation of the hash set that +is preallocated for +.Fa size +entries. +.Sh RETURN VALUES +If successful, +.Fn ck_hs_reset_size 3 +will return true and will otherwise return false on failure. This +function will only fail if a replacement hash set could not be +allocated internally. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_hs_init 3 , +.Xr ck_hs_destroy 3 , +.Xr CK_HS_HASH 3 , +.Xr ck_hs_iterator_init 3 , +.Xr ck_hs_next 3 , +.Xr ck_hs_get 3 , +.Xr ck_hs_put 3 , +.Xr ck_hs_set 3 , +.Xr ck_hs_remove 3 , +.Xr ck_hs_grow 3 , +.Xr ck_hs_count 3 , +.Xr ck_hs_reset 3 , +.Xr ck_hs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_set b/doc/ck_hs_set index 2c0b4a9..625ddb2 100644 --- a/doc/ck_hs_set +++ b/doc/ck_hs_set @@ -91,6 +91,7 @@ to accomodate key insertion. .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , .Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , .Xr ck_hs_stat 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_stat b/doc/ck_hs_stat index b4ad5a9..334e740 100644 --- a/doc/ck_hs_stat +++ b/doc/ck_hs_stat @@ -70,6 +70,7 @@ thread. .Xr ck_hs_remove 3 , .Xr ck_hs_grow 3 , .Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 +.Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 .Pp Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_count b/doc/ck_ht_count index d8c7e32..92d2089 100644 --- a/doc/ck_ht_count +++ b/doc/ck_ht_count @@ -58,7 +58,8 @@ has not been initialized. .Xr ck_ht_get_spmc 3 , .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_size_spmc 3 , +.Xr ck_ht_reset_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_destroy b/doc/ck_ht_destroy index 13b110c..a509a09 100644 --- a/doc/ck_ht_destroy +++ b/doc/ck_ht_destroy @@ -68,6 +68,7 @@ This function is guaranteed not to fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_entry_empty b/doc/ck_ht_entry_empty index 93b621f..385be4b 100644 --- a/doc/ck_ht_entry_empty +++ b/doc/ck_ht_entry_empty @@ -72,7 +72,8 @@ has not been initialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , .Xr ck_ht_entry_key 3 , diff --git a/doc/ck_ht_entry_key b/doc/ck_ht_entry_key index 88956db..651477a 100644 --- a/doc/ck_ht_entry_key +++ b/doc/ck_ht_entry_key @@ -70,7 +70,8 @@ has not been initialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_entry_key_direct b/doc/ck_ht_entry_key_direct index b00e5b5..a5ed16f 100644 --- a/doc/ck_ht_entry_key_direct +++ b/doc/ck_ht_entry_key_direct @@ -73,7 +73,8 @@ has not been initialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_entry_key_length b/doc/ck_ht_entry_key_length index 2635ff0..c0e1326 100644 --- a/doc/ck_ht_entry_key_length +++ b/doc/ck_ht_entry_key_length @@ -70,7 +70,8 @@ has not been initialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_entry_key_set b/doc/ck_ht_entry_key_set index 3f87455..0dd4628 100644 --- a/doc/ck_ht_entry_key_set +++ b/doc/ck_ht_entry_key_set @@ -75,7 +75,8 @@ This function will never fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set_direct 3 , .Xr ck_ht_entry_key 3 , diff --git a/doc/ck_ht_entry_key_set_direct b/doc/ck_ht_entry_key_set_direct index 03e2a4e..9d57444 100644 --- a/doc/ck_ht_entry_key_set_direct +++ b/doc/ck_ht_entry_key_set_direct @@ -70,7 +70,8 @@ This function will never fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key 3 , diff --git a/doc/ck_ht_entry_set b/doc/ck_ht_entry_set index ec99a22..b5c2f80 100644 --- a/doc/ck_ht_entry_set +++ b/doc/ck_ht_entry_set @@ -77,7 +77,8 @@ This function will never fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_set_direct 3 , .Xr ck_ht_entry_key 3 , diff --git a/doc/ck_ht_entry_set_direct b/doc/ck_ht_entry_set_direct index 3e32e6b..c446044 100644 --- a/doc/ck_ht_entry_set_direct +++ b/doc/ck_ht_entry_set_direct @@ -76,7 +76,8 @@ This function will never fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key 3 , .Xr ck_ht_entry_key_length 3 , diff --git a/doc/ck_ht_entry_value b/doc/ck_ht_entry_value index 9209937..c0ca3ef 100644 --- a/doc/ck_ht_entry_value +++ b/doc/ck_ht_entry_value @@ -70,7 +70,8 @@ has not been initialized or if the key is empty. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_entry_value_direct b/doc/ck_ht_entry_value_direct index c0580b7..9cdf022 100644 --- a/doc/ck_ht_entry_value_direct +++ b/doc/ck_ht_entry_value_direct @@ -71,7 +71,8 @@ has not been initialized or if the key is empty. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_get_spmc b/doc/ck_ht_get_spmc index ea5d0a3..c46f0c1 100644 --- a/doc/ck_ht_get_spmc +++ b/doc/ck_ht_get_spmc @@ -158,6 +158,7 @@ was not found in the hash table. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_grow_spmc b/doc/ck_ht_grow_spmc index 9dbf5e8..563fb92 100644 --- a/doc/ck_ht_grow_spmc +++ b/doc/ck_ht_grow_spmc @@ -79,6 +79,7 @@ if there are internal memory allocation failures. .Xr ck_ht_get_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_hash b/doc/ck_ht_hash index d7a1dc3..fe037e9 100644 --- a/doc/ck_ht_hash +++ b/doc/ck_ht_hash @@ -71,6 +71,7 @@ is uninitialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_hash_direct b/doc/ck_ht_hash_direct index 17afb9f..4ad5364 100644 --- a/doc/ck_ht_hash_direct +++ b/doc/ck_ht_hash_direct @@ -71,6 +71,7 @@ is uninitialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_init b/doc/ck_ht_init index 5304017..947ca97 100644 --- a/doc/ck_ht_init +++ b/doc/ck_ht_init @@ -164,6 +164,7 @@ object. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_iterator_init b/doc/ck_ht_iterator_init index e934880..6a2462b 100644 --- a/doc/ck_ht_iterator_init +++ b/doc/ck_ht_iterator_init @@ -71,7 +71,7 @@ This function will not fail. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_next b/doc/ck_ht_next index 30059dd..db298ac 100644 --- a/doc/ck_ht_next +++ b/doc/ck_ht_next @@ -89,7 +89,8 @@ are uninitialized. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_count 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ht_put_spmc b/doc/ck_ht_put_spmc index 0b5f7cf..38d78c9 100644 --- a/doc/ck_ht_put_spmc +++ b/doc/ck_ht_put_spmc @@ -127,6 +127,7 @@ was already present in the hash table. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_remove_spmc b/doc/ck_ht_remove_spmc index 7878799..f8ba2c6 100644 --- a/doc/ck_ht_remove_spmc +++ b/doc/ck_ht_remove_spmc @@ -98,6 +98,7 @@ will return .Xr ck_ht_get_spmc 3 , .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_reset_size_spmc b/doc/ck_ht_reset_size_spmc new file mode 100644 index 0000000..49cdc29 --- /dev/null +++ b/doc/ck_ht_reset_size_spmc @@ -0,0 +1,83 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 5, 2013 +.Dt CK_HT_RESET_SPMC 3 +.Sh NAME +.Nm ck_ht_reset_size_spmc +.Nd remove all entries from a hash table and reset size +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ht.h +.Ft bool +.Fn ck_ht_reset_size_spmc "ck_ht_t *ht" "uint64_t capacity" +.Sh DESCRIPTION +The +.Fn ck_ht_reset_size_spmc +function will remove all key-value pairs stored in the hash +table pointed to by the +.Fa ht +argument and create a new generation of the hash table that +is preallocated for +.Fa capacity +entries. +.Sh RETURN VALUES +If successful, +.Fn ck_ht_reset_size_spmc +will return +.Dv true +and will otherwise return +.Dv false. +This function will only fail if a replacement hash table +could not be allocated internally. +.Sh SEE ALSO +.Xr ck_ht_stat 3 , +.Xr ck_ht_init 3 , +.Xr ck_ht_destroy 3 , +.Xr ck_ht_hash 3 , +.Xr ck_ht_hash_direct 3 , +.Xr ck_ht_set_spmc 3 , +.Xr ck_ht_put_spmc 3 , +.Xr ck_ht_get_spmc 3 , +.Xr ck_ht_grow_spmc 3 , +.Xr ck_ht_remove_spmc 3 , +.Xr ck_ht_count 3 , +.Xr ck_ht_entry_empty 3 , +.Xr ck_ht_entry_key_set 3 , +.Xr ck_ht_entry_key_set_direct 3 , +.Xr ck_ht_entry_key 3 , +.Xr ck_ht_entry_key_length 3 , +.Xr ck_ht_entry_value 3 , +.Xr ck_ht_entry_set 3 , +.Xr ck_ht_entry_set_direct 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_entry_key_direct 3 , +.Xr ck_ht_entry_value_direct 3 , +.Xr ck_ht_iterator_init 3 , +.Xr ck_ht_next 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_reset_spmc b/doc/ck_ht_reset_spmc index 5b3af4c..ae072e0 100644 --- a/doc/ck_ht_reset_spmc +++ b/doc/ck_ht_reset_spmc @@ -62,6 +62,7 @@ could not be allocated internally. .Xr ck_ht_get_spmc 3 , .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_set_spmc b/doc/ck_ht_set_spmc index a466a5c..6bf9180 100644 --- a/doc/ck_ht_set_spmc +++ b/doc/ck_ht_set_spmc @@ -121,6 +121,7 @@ while attempting to grow. .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , .Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_count 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , diff --git a/doc/ck_ht_stat b/doc/ck_ht_stat index 1d1f55d..ab7d29c 100644 --- a/doc/ck_ht_stat +++ b/doc/ck_ht_stat @@ -66,7 +66,8 @@ has not been initialized. .Xr ck_ht_get_spmc 3 , .Xr ck_ht_grow_spmc 3 , .Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset 3 , +.Xr ck_ht_reset_spmc 3 , +.Xr ck_ht_reset_size_spmc 3 , .Xr ck_ht_entry_empty 3 , .Xr ck_ht_entry_key_set 3 , .Xr ck_ht_entry_key_set_direct 3 , diff --git a/doc/ck_ring_capacity b/doc/ck_ring_capacity new file mode 100644 index 0000000..0332433 --- /dev/null +++ b/doc/ck_ring_capacity @@ -0,0 +1,55 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_CAPACITY 3 +.Sh NAME +.Nm ck_ring_capacity +.Nd returns number of pointer slots in bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft unsigned int +.Fn ck_ring_capacity "ck_ring_t *ring" +.Sh DESCRIPTION +The +.Fn ck_ring_capacity 3 +function returns the number of pointers that can be +held in the buffer pointed to by +.Fa ring . +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_size b/doc/ck_ring_size new file mode 100644 index 0000000..7ec69f4 --- /dev/null +++ b/doc/ck_ring_size @@ -0,0 +1,55 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_SIZE 3 +.Sh NAME +.Nm ck_ring_size +.Nd return number of pointers enqueued in bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft unsigned int +.Fn ck_ring_size "ck_ring_t *ring" +.Sh DESCRIPTION +The +.Fn ck_ring_size 3 +function returns the number of pointers currently +enqueued in the buffer pointed to by +.Fa ring . +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/include/ck_epoch.h b/include/ck_epoch.h index 82d35cb..4624bdf 100644 --- a/include/ck_epoch.h +++ b/include/ck_epoch.h @@ -151,5 +151,6 @@ void ck_epoch_unregister(ck_epoch_t *, ck_epoch_record_t *); bool ck_epoch_poll(ck_epoch_t *, ck_epoch_record_t *); void ck_epoch_synchronize(ck_epoch_t *, ck_epoch_record_t *); void ck_epoch_barrier(ck_epoch_t *, ck_epoch_record_t *); +void ck_epoch_reclaim(ck_epoch_record_t *); #endif /* _CK_EPOCH_H */ diff --git a/include/ck_hs.h b/include/ck_hs.h index 07db610..dac5dc4 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -98,6 +98,7 @@ void *ck_hs_remove(ck_hs_t *, unsigned long, const void *); bool ck_hs_grow(ck_hs_t *, unsigned long); unsigned long ck_hs_count(ck_hs_t *); bool ck_hs_reset(ck_hs_t *); +bool ck_hs_reset_size(ck_hs_t *, unsigned long); void ck_hs_stat(ck_hs_t *, struct ck_hs_stat *); #endif /* _CK_HS_H */ diff --git a/include/ck_ht.h b/include/ck_ht.h index b218bfc..5900847 100644 --- a/include/ck_ht.h +++ b/include/ck_ht.h @@ -253,6 +253,7 @@ bool ck_ht_get_spmc(ck_ht_t *, ck_ht_hash_t, ck_ht_entry_t *); bool ck_ht_grow_spmc(ck_ht_t *, uint64_t); bool ck_ht_remove_spmc(ck_ht_t *, ck_ht_hash_t, ck_ht_entry_t *); bool ck_ht_reset_spmc(ck_ht_t *); +bool ck_ht_reset_size_spmc(ck_ht_t *, uint64_t); uint64_t ck_ht_count(ck_ht_t *); #endif /* CK_F_PR_LOAD_64 && CK_F_PR_STORE_64 */ diff --git a/regressions/ck_epoch/validate/ck_epoch_poll.c b/regressions/ck_epoch/validate/ck_epoch_poll.c index 8be273a..a9fb202 100644 --- a/regressions/ck_epoch/validate/ck_epoch_poll.c +++ b/regressions/ck_epoch/validate/ck_epoch_poll.c @@ -197,7 +197,7 @@ write_thread(void *unused CK_CC_UNUSED) } } - ck_epoch_synchronize(&stack_epoch, &record); + ck_epoch_barrier(&stack_epoch, &record); if (tid == 0) { fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[W] Peak: %u (%2.2f%%)\n Reclamations: %lu\n\n", diff --git a/regressions/ck_epoch/validate/ck_epoch_synchronize.c b/regressions/ck_epoch/validate/ck_epoch_synchronize.c index 960c99e..f5d68ab 100644 --- a/regressions/ck_epoch/validate/ck_epoch_synchronize.c +++ b/regressions/ck_epoch/validate/ck_epoch_synchronize.c @@ -192,7 +192,12 @@ write_thread(void *unused CK_CC_UNUSED) e = stack_container(s); ck_epoch_end(&stack_epoch, &record); - ck_epoch_synchronize(&stack_epoch, &record); + if (i & 1) { + ck_epoch_synchronize(&stack_epoch, &record); + ck_epoch_reclaim(&record); + } else { + ck_epoch_barrier(&stack_epoch, &record); + } if (i & 1) { ck_epoch_call(&stack_epoch, &record, &e->epoch_entry, destructor); diff --git a/regressions/ck_epoch/validate/ck_stack.c b/regressions/ck_epoch/validate/ck_stack.c index 55f74a1..204b3fc 100644 --- a/regressions/ck_epoch/validate/ck_stack.c +++ b/regressions/ck_epoch/validate/ck_stack.c @@ -124,7 +124,7 @@ thread(void *unused CK_CC_UNUSED) record.n_pending, record.n_dispatch); - ck_epoch_synchronize(&stack_epoch, &record); + ck_epoch_barrier(&stack_epoch, &record); ck_pr_inc_uint(&e_barrier); while (ck_pr_load_uint(&e_barrier) < (n_threads << 1)); diff --git a/regressions/ck_hs/benchmark/parallel_bytestring.c b/regressions/ck_hs/benchmark/parallel_bytestring.c index 7910ac2..53597e0 100644 --- a/regressions/ck_hs/benchmark/parallel_bytestring.c +++ b/regressions/ck_hs/benchmark/parallel_bytestring.c @@ -1,6 +1,6 @@ /* - * Copyrighs 2012 Samy Al Bahra. - * All righss reserved. + * Copyright 2012 Samy Al Bahra. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/regressions/ck_hs/benchmark/serial.c b/regressions/ck_hs/benchmark/serial.c index 5b1cf03..a1375fc 100644 --- a/regressions/ck_hs/benchmark/serial.c +++ b/regressions/ck_hs/benchmark/serial.c @@ -1,6 +1,6 @@ /* - * Copyrighs 2012 Samy Al Bahra. - * All righss reserved. + * Copyright 2012 Samy Al Bahra. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/regressions/ck_hs/validate/serial.c b/regressions/ck_hs/validate/serial.c index 26f237b..7e1ef31 100644 --- a/regressions/ck_hs/validate/serial.c +++ b/regressions/ck_hs/validate/serial.c @@ -1,5 +1,5 @@ /* - * Copyrighs 2012 Samy Al Bahra. + * Copyright 2012 Samy Al Bahra. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/regressions/common.h b/regressions/common.h index ce5aa92..ae3d314 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -42,7 +42,7 @@ #if defined(_WIN32) #include -#include +#define NOMINMAX #include #define DELTA_EPOCH 11644473600000000ULL #else diff --git a/src/ck_epoch.c b/src/ck_epoch.c index af23c93..1904748 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -275,11 +275,25 @@ ck_epoch_dispatch(struct ck_epoch_record *record, unsigned int e) return; } +/* + * Reclaim all objects associated with a record. + */ +void +ck_epoch_reclaim(struct ck_epoch_record *record) +{ + unsigned int epoch; + + for (epoch = 0; epoch < CK_EPOCH_LENGTH; epoch++) + ck_epoch_dispatch(record, epoch); + + return; +} + /* * This function must not be called with-in read section. */ void -ck_epoch_barrier(struct ck_epoch *global, struct ck_epoch_record *record) +ck_epoch_synchronize(struct ck_epoch *global, struct ck_epoch_record *record) { struct ck_epoch_record *cr; unsigned int delta, epoch, goal, i; @@ -322,7 +336,7 @@ ck_epoch_barrier(struct ck_epoch *global, struct ck_epoch_record *record) * we are at a grace period. */ if (active == false) - goto dispatch; + goto leave; /* * Increment current epoch. CAS semantics are used to eliminate @@ -349,7 +363,7 @@ reload: * generation. We can actually avoid an addtional scan step * at this point. */ - goto dispatch; + goto leave; } } @@ -376,26 +390,17 @@ reload: break; } - /* - * As the synchronize operation is non-blocking, it is possible other - * writers have already observed three or more epoch generations - * relative to the generation the caller has observed. In this case, - * it is safe to assume we are also in a grace period and are able to - * dispatch all calls across all lists. - */ -dispatch: - for (epoch = 0; epoch < CK_EPOCH_LENGTH; epoch++) - ck_epoch_dispatch(record, epoch); - +leave: record->epoch = delta; return; } void -ck_epoch_synchronize(struct ck_epoch *global, struct ck_epoch_record *record) +ck_epoch_barrier(struct ck_epoch *global, struct ck_epoch_record *record) { - ck_epoch_barrier(global, record); + ck_epoch_synchronize(global, record); + ck_epoch_reclaim(record); return; } diff --git a/src/ck_hs.c b/src/ck_hs.c index fb6e0e4..6c082e9 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -167,12 +167,12 @@ ck_hs_map_create(struct ck_hs *hs, unsigned long entries) } bool -ck_hs_reset(struct ck_hs *hs) +ck_hs_reset_size(struct ck_hs *hs, unsigned long capacity) { struct ck_hs_map *map, *previous; previous = hs->map; - map = ck_hs_map_create(hs, previous->capacity); + map = ck_hs_map_create(hs, capacity); if (map == NULL) return false; @@ -181,6 +181,15 @@ ck_hs_reset(struct ck_hs *hs) return true; } +bool +ck_hs_reset(struct ck_hs *hs) +{ + struct ck_hs_map *previous; + + previous = hs->map; + return ck_hs_reset_size(hs, previous->capacity); +} + static inline unsigned long ck_hs_map_probe_next(struct ck_hs_map *map, unsigned long offset, diff --git a/src/ck_ht.c b/src/ck_ht.c index 3f5ea2f..069ce85 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -453,12 +453,12 @@ ck_ht_next(struct ck_ht *table, } bool -ck_ht_reset_spmc(struct ck_ht *table) +ck_ht_reset_size_spmc(struct ck_ht *table, uint64_t size) { struct ck_ht_map *map, *update; map = table->map; - update = ck_ht_map_create(table, map->capacity); + update = ck_ht_map_create(table, size); if (update == NULL) return false; @@ -467,6 +467,14 @@ ck_ht_reset_spmc(struct ck_ht *table) return true; } +bool +ck_ht_reset_spmc(struct ck_ht *table) +{ + struct ck_ht_map *map = table->map; + + return ck_ht_reset_size_spmc(table, map->capacity); +} + bool ck_ht_grow_spmc(ck_ht_t *table, uint64_t capacity) {