62 auto_synchronizer critical_section(__loggers_lock()); \
63 CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)); \
72static int chars_printed = 0;
75#define BASE_LOG(s) { \
76 auto_synchronizer critical_section(__loggers_lock()); \
78 ted().eol(parser_bits::NO_ENDING); \
80 int len = joe.length(); \
82 if (chars_printed + len > MAXIMUM_CHARS_PER_LINE) { \
83 ted().log(astring("\n"), basis::ALWAYS_PRINT); \
86 chars_printed += len; \
87 ted().log(joe, basis::ALWAYS_PRINT); \
95class bool_scared_ya :
public root_object {
97 bool_scared_ya(
bool init =
false) : _value(init) {}
98 bool_scared_ya &operator = (
const bool_scared_ya &s1) { _value = s1._value;
return *
this; }
99 bool_scared_ya &operator = (
bool s1) { _value = s1;
return *
this; }
100 virtual ~bool_scared_ya() {}
101 operator bool() {
return _value; }
106SAFE_STATIC(bool_scared_ya, __threads_can_run_wild_and_free, (
false));
159#define randomizer() _rando()
175 process_id, sequencer, add_in);
180 int process_id =
randomizer().inclusive(1, 4);
182 process_id, sequencer, add_in);
192class ballot_box_stuffer :
public ethread
197 LOG(
">> new creator >>");
200 virtual ~ballot_box_stuffer() {
202 LOG(
"<< creator exits <<");
213 for (
int i = 0; i < how_many; i++) {
215 int string_count =
randomizer().inclusive(1, 10);
217 for (
int q = 0; q < string_count; q++) {
241class vote_destroyer :
public ethread
246 LOG(
">> new destroyer >>");
249 virtual ~vote_destroyer() {
251 LOG(
"<< destroyer exits <<");
261 for (
int i = 0; i < how_many; i++) {
283class obsessive_compulsive :
public ethread
288 LOG(
">> new cleaner >>");
291 virtual ~obsessive_compulsive() {
293 LOG(
"<< cleaner exits <<");
314class monk_the_detective :
public ethread
319 LOG(
">> new monk >>");
322 virtual ~monk_the_detective() {
324 LOG(
"<< monk exits <<");
331 if (!__threads_can_run_wild_and_free() || !_hit_first_activation) {
332 _hit_first_activation =
true;
337 _hit_first_activation =
true;
360LOG(
a_sprintf(
"monk manually cleaned %d items very carefully...", check_count));
372 bool _hit_first_activation;
390int test_entity_data_bin_threaded::execute()
397 if (duration_string.
length()) {
399 LOG(
a_sprintf(
"user specified runtime duration of %d seconds.", duration));
414 t =
new monk_the_detective;
415 }
else if (i % 3 == 0) {
416 t =
new ballot_box_stuffer;
417 }
else if (i % 3 == 1) {
418 t =
new vote_destroyer;
420 t =
new obsessive_compulsive;
425 deadly_error(class_name(), func,
"amorph has incorrect pointer!");
431 __threads_can_run_wild_and_free() =
true;
438 __threads_can_run_wild_and_free() =
false;
444 LOG(
"now cancelling all threads...");
445 for (
int j = 0; j < thread_list.
elements(); j++) { thread_list[j]->cancel(); }
446 LOG(
"now resetting thread list...");
448 LOG(
"...done exiting from all threads.");
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
int convert(int default_value) const
Converts the string into a corresponding integer.
int length() const
Returns the current length of the string.
auto_synchronizer simplifies concurrent code by automatically unlocking.
static void alert_message(const char *info, const char *title="Alert Message")
shows the message in "info", with an optional "title" on the message.
a platform-independent way to acquire random numbers in a specific range.
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.
int sleep_time() const
returns the current periodic thread interval.
virtual void perform_activity(void *thread_data)=0
< invoked just after after start(), when the OS thread is created.
int elements() const
the maximum number of elements currently allowed in this amorph.
basis::outcome append(const contents *data)
puts "data" on the end of this amorph.
void reset()
cleans out all of the contents.
An array of strings with some additional helpful methods.
static basis::astring make_random_name(int min=1, int max=64)
creates a random name, where the letters are between 'a' and 'z'.
static void sleep_ms(basis::un_int msec)
a system independent name for a forced snooze measured in milliseconds.
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 MAXINT32
Maximum 32-bit integer value.
#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.
The guards collection helps in testing preconditions and reporting errors.
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.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define SAFE_STATIC(type, func_name, parms)
Statically defines a singleton object whose scope is the program's lifetime.
octopus_request_id create_request_id()
const int MIN_ADDER_THREAD_PAUSE
entity_data_bin binger(MAXIMUM_DATA_PER_ENTITY)
const int MINIMUM_ITEMS_HANDLED
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 MAXIMUM_ITEMS_HANDLED
const int DEFAULT_THREADS
const int MAXIMUM_CHARS_PER_LINE
const int MAX_WHACKER_THREAD_PAUSE
const int MIN_MONK_THREAD_PAUSE
const int MAX_ADDER_THREAD_PAUSE
const int MIN_TIDIER_THREAD_PAUSE
const int MONKS_CLEANING_TIME
const int MAXIMUM_DATA_PER_ENTITY