KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
concurrency.cpp File Reference
#include <iostream>
#include <atomic>
#include <array>
#include <future>
#include <chrono>
#include <functional>
#include <coroutine>
#include <semaphore>
#include <thread>
#include <barrier>
#include <cstdlib>
#include <latch>
#include <syncstream>
#include <shared_mutex>
#include <condition_variable>
#include <stop_token>
#include <span>
#include <random>
#include <exception>
#include <string>
#include <dc/wdt.h>

Typedefs

using chamber_t = uint32_t
 

Functions

static void run_semaphore (std::binary_semaphore &sem_main_to_thread, std::binary_semaphore &sem_thread_to_main)
 
static void test_semaphore ()
 
static void test_latch ()
 
static void test_shared_lock ()
 
static void run_condition_variable (CondVarState &cond_variable_state)
 
static void test_condition_variable ()
 
static void send_mail (Employee &, Employee &)
 
static void assign_lunch_partner (Employee &e1, Employee &e2)
 
static void test_scoped_lock ()
 
static void test_barrier ()
 
static void run_stop_source (int id, std::stop_source stop_source, std::atomic< unsigned > &counter)
 
static void test_stop_source ()
 
static auto select_chamber () -> chamber_t
 
static auto player (std::size_t id, bool &fired, trigger_t &trigger) -> user_behavior_t
 
auto defer (auto &&f)
 
static void russian_roulette (revolver_t &revolver, std::span< user_behavior_t > users)
 
static void test_coroutines ()
 
int main (int argc, char *argv[])
 

Variables

constexpr unsigned WATCHDOG_TIMEOUT = (20 * 1000 * 1000)
 
constexpr int THREAD_COUNT = 10
 

Typedef Documentation

◆ chamber_t

Function Documentation

◆ assign_lunch_partner()

static void assign_lunch_partner ( Employee & e1,
Employee & e2 )
static

References lock, and send_mail().

Referenced by test_scoped_lock().

◆ defer()

auto defer ( auto && f)

Referenced by russian_roulette().

◆ main()

int main ( int argc,
char * argv[] )

◆ player()

static auto player ( std::size_t id,
bool & fired,
trigger_t & trigger ) -> user_behavior_t
static

Referenced by russian_roulette().

◆ run_condition_variable()

static void run_condition_variable ( CondVarState & cond_variable_state)
static

Referenced by test_condition_variable().

◆ run_semaphore()

static void run_semaphore ( std::binary_semaphore & sem_main_to_thread,
std::binary_semaphore & sem_thread_to_main )
static

References ms.

Referenced by test_semaphore().

◆ run_stop_source()

static void run_stop_source ( int id,
std::stop_source stop_source,
std::atomic< unsigned > & counter )
static

References counter, and ms.

Referenced by test_stop_source().

◆ russian_roulette()

static void russian_roulette ( revolver_t & revolver,
std::span< user_behavior_t > users )
static

References defer(), and player().

Referenced by test_coroutines().

◆ select_chamber()

static auto select_chamber ( ) -> chamber_t
static

Referenced by test_coroutines().

◆ send_mail()

static void send_mail ( Employee & ,
Employee &  )
static

Referenced by assign_lunch_partner().

◆ test_barrier()

static void test_barrier ( )
static

References phase.

◆ test_condition_variable()

static void test_condition_variable ( )
static

◆ test_coroutines()

static void test_coroutines ( )
static

◆ test_latch()

static void test_latch ( )
static

◆ test_scoped_lock()

static void test_scoped_lock ( )
static

References assign_lunch_partner(), and thread().

◆ test_semaphore()

static void test_semaphore ( )
static

References run_semaphore().

◆ test_shared_lock()

static void test_shared_lock ( )
static

References counter.

◆ test_stop_source()

static void test_stop_source ( )
static

References counter, ms, print, and run_stop_source().

Variable Documentation

◆ THREAD_COUNT

int THREAD_COUNT = 10
inlineconstexpr

Referenced by main().

◆ WATCHDOG_TIMEOUT

unsigned WATCHDOG_TIMEOUT = (20 * 1000 * 1000)
inlineconstexpr

Referenced by main().