A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://gammasoft71.github.io/xtd/reference_guides/latest/group__threading.html below:

xtd: threading

#include <xtd/xtd>

namespace examples {

class

account :

public object

{

public:

explicit account(int initial) : balance(initial) {}

void do_transactions() {

for (auto i = 0; i < 100; ++i)

withdraw(random.next(1, 100));

}

private:

int withdraw(int amount) {

if (balance < 0) throw system_exception {"Negative Balance"};

if (balance < amount) return 0;

console::write_line("Balance before Withdrawal : {0}", balance);

console::write_line("Amount to Withdraw : -{0}", amount);

balance = balance - amount;

console::write_line("Balance after Withdrawal : {0}", balance);

return amount;

}

return 0;

}

int balance = 0;

xtd::random random;

};

class program {

public:

static void main() {

auto account = examples::account {1000};

for

(

auto

i = 0;

i

< 10; ++

i

)

thread_pool::queue_user_work_item({account, &account::do_transactions});

thread_pool::close();

}

};

}

Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....

Definition object.hpp:44

#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:168

#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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4