summaryrefslogtreecommitdiff
path: root/yhttpd-0.7.0/src/maps/smap.h
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
commit9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (patch)
tree631c295a4a4a16b57502b847626763a279bf6df7 /yhttpd-0.7.0/src/maps/smap.h
parent13aaf70af703748fe096e0664c305cd202637ad2 (diff)
tagging tags
Diffstat (limited to 'yhttpd-0.7.0/src/maps/smap.h')
-rw-r--r--yhttpd-0.7.0/src/maps/smap.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/yhttpd-0.7.0/src/maps/smap.h b/yhttpd-0.7.0/src/maps/smap.h
new file mode 100644
index 0000000..e056519
--- /dev/null
+++ b/yhttpd-0.7.0/src/maps/smap.h
@@ -0,0 +1,56 @@
+// smap := Syncronized hmap
+// nmap := Syncronized hmap which's get_elem returns a new obj_type
+// instance instead of NULL if for a specific key no value has
+// been found
+
+#include "../incl.h"
+
+#ifndef SMAP_H
+#define SMAP_H
+
+#include "hmap.h"
+
+template <class obj_type, class key_type>
+class smap : public hmap<obj_type, key_type>
+{
+
+ private:
+ pthread_mutex_t mut_smap;
+
+ protected:
+ void lock_mutex();
+ void unlock_mutex();
+
+ public:
+ smap( double moc );
+ ~smap();
+ int get_size();
+ void make_empty();
+ void make_empty( void (*func)(key_type) );
+ void add_elem ( const obj_type &x, const key_type &k );
+ obj_type set_elem ( const obj_type &x, const key_type &k );
+ void del_elem ( const key_type &k );
+ bool is_avail ( const key_type &k );
+ obj_type get_elem ( const key_type &k );
+ obj_type pop_elem ( const key_type &k );
+ void run_func( void (*func)(obj_type) );
+ void run_func( void (*func)(obj_type, void*), void* v_arg );
+ void run_func_on( void (*func)(obj_type), const key_type &k );
+ vector<key_type>* get_key_vector();
+
+ int get_size_insecure();
+ void make_empty_insecure();
+ void make_empty_insecure( void (*func)(key_type) );
+ void add_elem_insecure ( const obj_type &x, const key_type &k );
+ void del_elem_insecure ( const key_type &k );
+ bool is_avail_insecure ( const key_type &k );
+ obj_type get_elem_insecure ( const key_type &k );
+ obj_type pop_elem_insecure ( const key_type &k );
+ void run_func_insecure( void (*func)(obj_type) );
+ void run_func_insecure( void (*func)(obj_type, void*), void* v_arg );
+ vector<key_type>* get_key_vector_insecure();
+};
+
+#include "smap.tmpl"
+
+#endif