88 #define LOG(to_print) printf("%s\n", (char *)astring(to_print).s());
98 #define randomizer() _rando
108 int sequencer =
randomizer().inclusive(1, MAXINT - 10);
109 int add_in =
randomizer().inclusive(0, MAXINT - 10);
110 int process_id =
randomizer().inclusive(0, MAXINT - 10);
112 process_id, sequencer, add_in);
117 int process_id =
randomizer().inclusive(1, 4);
119 process_id, sequencer, add_in);
126 class ballot_box_stuffer :
public ethread
129 ballot_box_stuffer() :
ethread(0) {
134 virtual ~ballot_box_stuffer() {
141 void perform_activity(
void *
formal(data)) {
143 while (!should_stop()) {
147 for (
int i = 0; i < how_many; i++) {
149 int string_count =
randomizer().inclusive(1, 10);
151 for (
int q = 0; q < string_count; q++) {
152 random_strings += string_manipulation::make_random_name();
161 time_control::sleep_ms(sleepy_time);
168 class vote_destroyer :
public ethread
171 vote_destroyer() :
ethread(0) {
176 virtual ~vote_destroyer() {
183 void perform_activity(
void *
formal(data)) {
185 while (!should_stop()) {
193 time_control::sleep_ms(sleepy_time);
199 class obsessive_compulsive :
public ethread
202 obsessive_compulsive() :
ethread(0) {
207 virtual ~obsessive_compulsive() {
214 void perform_activity(
void *
formal(data)) {
216 while (!should_stop()) {
222 time_control::sleep_ms(sleepy_time);
228 class monk_the_detective :
public ethread
231 monk_the_detective() :
ethread(0) {
236 virtual ~monk_the_detective() {
243 void perform_activity(
void *
formal(data)) {
245 while (!should_stop()) {
264 time_control::sleep_ms(sleepy_time);
281 int test_entity_data_bin_threaded::execute()
285 amorph<ethread> thread_list;
291 t =
new monk_the_detective;
292 }
else if (i % 3 == 0) {
293 t =
new ballot_box_stuffer;
294 }
else if (i % 3 == 1) {
295 t =
new vote_destroyer;
297 t =
new obsessive_compulsive;
299 thread_list.append(t);
300 ethread *q = thread_list[thread_list.elements() - 1];
302 deadly_error(class_name(), func,
"amorph has incorrect pointer!");
304 thread_list[thread_list.elements() - 1]->start(
NULL_POINTER);
309 time_control::sleep_ms(100);
324 LOG(
"done exiting from all threads....");
332 guards::alert_message(
"t_bin_threaded:: works for all functions tested.");
The application_shell is a base object for console programs.
void lock()
Clamps down on the mutex, if possible.
void unlock()
Gives up the possession of the mutex.
Stores a set of infotons grouped by the entity that owns them.
bool add_item(infoton *to_add, const octopus_request_id &id)
infoton * acquire_for_any(octopus_request_id &id)
void clean_out_deadwood(int decay_interval=4 *basis::MINUTE_ms)
An infoton is an individual request parcel with accompanying information.
Provides a way of identifying users of an octopus object.
Identifies requests made on an octopus by users.
int _request_num
the item number from the entity.
octopus_entity _entity
the entity.
Informs the caller that a request type was unknown to the server octopus.
Provides a platform-independent object for adding threads to a program.
Represents a point in time relative to the operating system startup time.
#define deadly_error(c, f, i)
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
#define NULL_POINTER
The value representing a pointer to nothing.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
const int SECOND_ms
Number of milliseconds in a second.
const int MINUTE_ms
Number of milliseconds in a minute.
const int KILOBYTE
Number of bytes in a kilobyte.
A logger that sends to the console screen using the standard output device.
const int MINIMUM_ITEMS_ADDED
octopus_request_id create_request_id()
const int MIN_ADDER_THREAD_PAUSE
entity_data_bin binger(MAXIMUM_DATA_PER_ENTITY)
const int MAX_MONK_THREAD_PAUSE
const int MAX_TIDIER_THREAD_PAUSE
const int DATA_DECAY_TIME
const int DEFAULT_RUN_TIME
const int MIN_WHACKER_THREAD_PAUSE
const int DEFAULT_THREADS
const int MAX_WHACKER_THREAD_PAUSE
const int MIN_MONK_THREAD_PAUSE
const int MAXIMUM_ITEMS_ADDED
const int MAX_ADDER_THREAD_PAUSE
const int MIN_TIDIER_THREAD_PAUSE
const int MONKS_CLEANING_TIME
const int MAXIMUM_DATA_PER_ENTITY
string_array(1, math_list))) const char *addr_list[]