/**
Template parameters:
- GC - garbage collector used
- - Tag - this argument serves as \ref cds_intrusive_hook_tag "a tag"
+ - Tag - a \ref cds_intrusive_hook_tag "tag"
*/
template <class GC, typename Tag = opt::none >
using node = cds::intrusive::single_link::node< GC, Tag > ;
/**
\p Options are:
- opt::gc - garbage collector used.
- - opt::tag - \ref cds_intrusive_hook_tag "a tag"
+ - opt::tag - a \ref cds_intrusive_hook_tag "tag"
*/
template < typename... Options >
using base_hook = cds::intrusive::single_link::base_hook< Options...>;
\p Options are:
- opt::gc - garbage collector used.
- - opt::tag - \ref cds_intrusive_hook_tag "a tag"
+ - opt::tag - a \ref cds_intrusive_hook_tag "tag"
*/
template < size_t MemberOffset, typename... Options >
using member_hook = cds::intrusive::single_link::member_hook< MemberOffset, Options... >;
\p Options are:
- opt::gc - garbage collector used.
- - opt::tag - \ref cds_intrusive_hook_tag "a tag"
+ - opt::tag - a \ref cds_intrusive_hook_tag "tag"
*/
template <typename NodeTraits, typename... Options >
using traits_hook = cds::intrusive::single_link::traits_hook< NodeTraits, Options... >;
This is a wrapper for <tt> cds::opt::make_options< type_traits, Options...> </tt>
Supported \p Options are:
- - opt::hook - hook used. Possible values are: \p treiber_stack::base_hook, \p treiber_stack::member_hook, \p treiber_stack::traits_hook.
+ - opt::hook - hook used. Possible values are: treiber_stack::base_hook, treiber_stack::member_hook, treiber_stack::traits_hook.
If the option is not specified, \p %treiber_stack::base_hook<> is used.
- opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
- opt::disposer - the functor used for dispose removed items. Default is \p opt::v::empty_disposer. This option is used only
Template arguments:
- \p GC - garbage collector type: gc::HP, gc::PTB.
- Garbage collecting schema must be consistent with the treiber_stack::node GC.
+ Garbage collecting schema must be consistent with the \p treiber_stack::node GC.
- \p T - type to be inserted into the stack
- \p Traits - stack traits, default is \p treiber_stack::traits. You can use \p treiber_stack::make_traits
metafunction to make your traits or just derive your traits from \p %treiber_stack::traits:
typedef cds::intrusive::treiber_stack::stat<> stat;
};
typedef cds::intrusive::TreiberStack< cds::gc::HP, Foo, myTraits > myStack;
+
+ // Equivalent make_traits example:
+ typedef cds::intrusive::TreiberStack< cds::gc::HP, Foo,
+ typename cds::intrusive::treiber_stack::make_traits<
+ cds::opt::stat< cds::intrusive::treiber_stack::stat<> >
+ >::type
+ > myStack;
\endcode
@note Be careful when you want destroy an item popped, see \ref cds_intrusive_item_destroying "Destroying items of intrusive containers".
Example of how to use \p treiber_stack::base_hook.
Your class that objects will be pushed on \p %TreiberStack should be based on \p treiber_stack::node class
\code
- #include <cds/intrusive/stack/treiber_stack.h>
+ #include <cds/intrusive/treiber_stack.h>
#include <cds/gc/hp.h>
namespace ci = cds::intrusive;
// Stack type
typedef ci::TreiberStack< gc,
myData,
- ci::opt::hook< ci::treiber_stack::base_hook< gc > >
+ typename cds::intrusive::treiber_stack::make_traits<
+ ci::opt::hook< ci::treiber_stack::base_hook< gc > >
+ >::type
> stack_t;
// Stack with elimination back-off enabled
Example of how to use \p treiber_stack::base_hook with different tags.
\code
- #include <cds/intrusive/stack/treiber_stack.h>
+ #include <cds/intrusive/treiber_stack.h>
#include <cds/gc/hp.h>
namespace ci = cds::intrusive;
typedef ci::TreiberStack< gc,
myData,
typename ci::treiber_stack::make_traits<
- ci::opt::hook< ci::treiber_stack::base_hook< gc, tag2 >
+ ci::opt::hook< ci::treiber_stack::base_hook< gc, tag2 > >
>::type
> stack2_t;
- // You may add myData objects in the objects of type stack1_t and stack2_t independently
+ // You may add myData objects into stack1_t and stack2_t independently
void foo() {
stack1_t s1;
stack2_t s2;
Your class that will be pushed on \p %TreiberStack should have a member of type \p treiber_stack::node
\code
#include <stddef.h> // offsetof macro
- #include <cds/intrusive/stack/treiber_stack.h>
+ #include <cds/intrusive/treiber_stack.h>
#include <cds/gc/hp.h>
namespace ci = cds::intrusive;
typedef ci::TreiberStack< gc,
myData,
typename ci::treiber_stack::make_traits<
- ci::opt::hook< ci::treiber_stack::member_hook< offsetof(myData, member_hook_), gc >
+ ci::opt::hook< ci::treiber_stack::member_hook< offsetof(myData, member_hook_), gc >>
>::type
> stack_t;
\endcode
+++ /dev/null
-\r
-\r
-sub processDir( $ )\r
-{\r
- my $dirName = shift ;\r
- \r
- opendir(my $dh, $dirName) || die "can't opendir $dirName: $!";\r
- my @files = grep { /^[^\.]/ } readdir($dh);\r
- closedir $dh;\r
- \r
- foreach my $file ( @files ) {\r
- if ( -d "$dirName/$file" ) {\r
- processDir("$dirName/$file") ;\r
- }\r
- elsif ( $file =~ /\.(h|cpp)$/ ) {\r
- processFile( "$dirName/$file" ) ;\r
- }\r
- }\r
-}\r
-\r
-sub processFile( $ ) \r
-{\r
- my $file = shift ;\r
- \r
- if ( open( my $fh, $file )) {\r
- binmode $fh ;\r
- my $str = '' ;\r
- my $bTabified = 0 ;\r
- while (<$fh>) {\r
- my $s = $_ ;\r
- if ( $str eq '' ) {\r
- unless ( $s =~ m#//\$\$CDS-header\$\$# ) {\r
- $str .= '//$$CDS-header$$'."\n\n" ;\r
- $bTabified = 1 ;\r
- }\r
- }\r
- while ( $s =~ /\t/ ) {\r
- #print "pos=", $+[0], "\n" ;\r
- $bTabified = 1 ;\r
- my $pos = $+[0] ;\r
- if ( $pos ) {\r
- $pos -= 1 ;\r
- if ( $pos % 4 == 0 ) {\r
- $s =~ s/\t/ / ;\r
- }\r
- elsif ( $pos % 4 == 1 ) {\r
- $s =~ s/\t/ / ;\r
- }\r
- elsif ( $pos % 4 == 2 ) {\r
- $s =~ s/\t/ / ;\r
- }\r
- elsif ( $pos % 4 == 3 ) {\r
- $s =~ s/\t/ / ;\r
- }\r
- }\r
- }\r
- $bTabified = 1 if $s =~ s/[\t ]+([\n\r]+)$/$1/ ;\r
- $str .= $s ;\r
- }\r
- close $fh ;\r
- \r
- if ( $bTabified ) {\r
- print $file, "\n" ;\r
- if ( open( my $fh, ">$file" )) {\r
- binmode $fh ;\r
- print $fh $str ;\r
- close $fh ;\r
- }\r
- }\r
- }\r
-}\r
-\r
-chdir ('..') ;\r
-processDir('cds') ;\r
-processDir('src') ;\r
-processDir('tests/unit') ;\r
-\r
-exit;
\ No newline at end of file