#include "hashtable.h"
#include "lwt.h"
#include "mem.h"
+#include "rcu.h"
#define ASSERT_EQUAL(x, y) CuAssertIntEquals(tc, x, y)
map_t *map = wd->map;
CuTest* tc = wd->tc;
int d = wd->id;
- int iters = 10000;
+ int iters = (map_type_ == &MAP_IMPL_LL ? 10000 : 100000);
- SYNC_ADD(wd->wait, -1);
+ (void)SYNC_ADD(wd->wait, -1);
do { } while (*wd->wait); // wait for all workers to be ready
map_key_t key;
pthread_t thread[2];
worker_data_t wd[2];
- static const int num_threads = 2;
- volatile int wait = num_threads;
+ volatile int wait = 2;
#ifdef TEST_STRING_KEYS
map_t *map = map_alloc(map_type_, &DATATYPE_NSTRING);
#else
// In 2 threads, add & remove even & odd elements concurrently
int i;
- for (i = 0; i < num_threads; ++i) {
+ for (i = 0; i < 2; ++i) {
wd[i].id = i;
wd[i].tc = tc;
wd[i].map = map;
if (rc != 0) { perror("nbd_thread_create"); return; }
}
- for (i = 0; i < num_threads; ++i) {
+ for (i = 0; i < 2; ++i) {
pthread_join(thread[i], NULL);
}
gettimeofday(&tv2, NULL);
int ms = (int)(1000000*(tv2.tv_sec - tv1.tv_sec) + tv2.tv_usec - tv1.tv_usec) / 1000;
map_print(map);
- printf("Th:%d Time:%dms\n", num_threads, ms);
+ printf("Time:%dms\n", ms);
fflush(stdout);
// In the end, all members should be removed
}
int main (void) {
+ lwt_set_trace_level("r0m3l2t0");
- nbd_init();
- lwt_set_trace_level("h3");
-
- static const map_impl_t *map_types[] = { &ll_map_impl, &sl_map_impl, &ht_map_impl };
+ static const map_impl_t *map_types[] = { &MAP_IMPL_LL, &MAP_IMPL_SL, &MAP_IMPL_HT };
for (int i = 0; i < sizeof(map_types)/sizeof(*map_types); ++i) {
map_type_ = map_types[i];
CuString *output = CuStringNew();
CuSuite* suite = CuSuiteNew();
- SUITE_ADD_TEST(suite, basic_test);
- SUITE_ADD_TEST(suite, basic_iteration_test);
- SUITE_ADD_TEST(suite, big_iteration_test);
SUITE_ADD_TEST(suite, concurrent_add_remove_test);
+// SUITE_ADD_TEST(suite, basic_test);
+// SUITE_ADD_TEST(suite, basic_iteration_test);
+// SUITE_ADD_TEST(suite, big_iteration_test);
CuSuiteRun(suite);
CuSuiteDetails(suite, output);