int main(int argc, char **argv) { install_default_signal_handler(); struct tesla_store *global_store, *perthread; check(tesla_store_get(TESLA_SCOPE_GLOBAL, CLASSES, 1, &global_store)); check(tesla_store_get(TESLA_SCOPE_PERTHREAD, CLASSES, 1, &perthread)); check_store(global_store); check_store(perthread); return 0; }
int main(int argc, char **argv) { install_default_signal_handler(); const int scope = TESLA_SCOPE_GLOBAL; const int instances_in_class = 10; struct tesla_store *store; check(tesla_store_get(scope, 1, instances_in_class, &store)); // Test the following sequence of automata update events: // // (X,X,X,X): 0->1 new (X,X,X,X):1 // (1,X,X,X): 1->2 fork (X,X,X,X):1 -> (1,X,X,X):2 // (1,2,X,X): 2->3 fork (1,X,X,X):2 -> (1,2,X,X):3 // (1,2,X,X): 3->4 update (1,X,X,X):4 -> (1,2,X,X):4 // (2,X,X,X): 1->5 fork (X,X,X,X):1 -> (2,X,X,X):5 // (2,X,X,3): 5->6 fork (2,X,X,X):5 -> (2,X,X,3):6 // (2,X,X,4): 1->7 fork (X,X,X,X):1 -> (2,X,X,4):7 struct tesla_key key; const struct tesla_key any = { .tk_mask = 0 },
int main(int argc, char **argv) { install_default_signal_handler(); struct tesla_store *global_store; struct tesla_class *glob_automaton; check(tesla_store_get(TESLA_CONTEXT_GLOBAL, 1, 3, &global_store)); check(tesla_class_get(global_store, &glob, &glob_automaton)); struct tesla_store *perthread_store; struct tesla_class *thr_automaton; check(tesla_store_get(TESLA_CONTEXT_THREAD, 1, 3, &perthread_store)); check(tesla_class_get(perthread_store, &thr, &thr_automaton)); /* Create some automata instances. */ create_instance(glob_automaton, &instances[0], 42, 0, 1000); create_instance(glob_automaton, &instances[1], 43, 0, 1000); create_instance(glob_automaton, &instances[2], 42, 0, -1); create_instance(thr_automaton, &instances[3], 42, 0, 1000); create_instance(thr_automaton, &instances[4], 43, 1, 1000); create_instance(thr_automaton, &instances[5], 42, 1, -1); // Make sure they are all unique; this is n^2, but n is small. for (int32_t i = 0; i < INSTANCES; i++) { for (int32_t j = 0; j < INSTANCES; j++) { if (i == j) continue; assert(instances[i] != instances[j]); } } // Ok, let's go looking for automata instances! struct tesla_key pattern; // keys[0] == 42 => {0,2,3,5} pattern.tk_mask = 1 << 0; pattern.tk_keys[0] = 42; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x2D ); // keys[1] == 0 => {0,1,2,3} pattern.tk_mask = 1 << 1; pattern.tk_keys[1] = 0; // the value 0 is not special assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x0F ); // keys[2] == -1 => {2,5} pattern.tk_mask = 1 << 2; pattern.tk_keys[2] = -1; // the value -1 is not special, either assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x24 ); // keys[0] == 42 && keys[1] == 1 => {5} pattern.tk_mask = (1 << 0) + (1 << 1); pattern.tk_keys[0] = 42; pattern.tk_keys[1] = 1; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x20 ); // 'ANY' pattern => all pattern.tk_mask = 0; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x3F ); tesla_class_put(glob_automaton); tesla_class_put(thr_automaton); return 0; }