#include <xtd/threading/thread_pool>
#include <xtd/console>
#include <xtd/lock>
#include <xtd/random>
#include <xtd/startup>
namespace examples {
class account :
public object {
public:
explicit account(int initial) : balance(initial) {}
void do_transactions() {
for (
auto i = 0;
i < 100; ++
i)
}
private:
int withdraw(int amount) {
if (balance < amount) return 0;
balance = balance - amount;
return amount;
}
return 0;
}
int balance = 0;
};
class program {
public:
static void main() {
auto account = examples::account {1000};
for (
auto i = 0;
i < 10; ++
i)
}
};
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet c...
Definition random.hpp:43
virtual int32 next() const
Returns a nonnegative random number.
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.hpp:18
static void close()
Close all resources and worker threads.
static bool queue_user_work_item(const wait_callback &callback)
Queues a method for execution. The method executes when a thread pool thread becomes available.
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
#define lock_(object)
The lock_ keyword marks a statement block as a critical section by obtaining the mutual-exclusion loc...
Definition lock.hpp:85
@ i
The I key.
Definition console_key.hpp:104
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8