Texture TextureBuilder::Build2DTexture(TextureBindpoint target, unsigned width, unsigned height, unsigned count, unsigned channels, TexturePixelFormat pixelFormat, bool useMipmaps) { int current_id = id.fetch_add(1, std::memory_order_relaxed); Texture result; result.info.width = width; result.info.height = height; result.info.count = count; result.info.type = TextureType::Tex2D; result.info.target = target; result.info.targetPixelFormat = pixelFormat; result.info.channels = channels; result.info.name = std::string(NAME_PREFIX) + std::to_string(current_id); unsigned minSize = std::min(width, height); if (useMipmaps) { unsigned i = 0; while (minSize > 1) { minSize /= 2; i++; } result.info.mipmaps = i; } return result; }
void* initializeNotifier(void (*process)(uint64_t, void*), void *param, int32_t *status) { if (!process) { *status = NULL_PARAMETER; return nullptr; } if (!notifierAtexitRegistered.test_and_set()) std::atexit(cleanupNotifierAtExit); if (notifierRefCount.fetch_add(1) == 0) { std::lock_guard<priority_mutex> sync(notifierInterruptMutex); // create manager and alarm if not already created if (!notifierManager) { notifierManager = new tInterruptManager(1 << kTimerInterruptNumber, false, status); notifierManager->registerHandler(alarmCallback, NULL, status); notifierManager->enable(status); } if (!notifierAlarm) notifierAlarm = tAlarm::create(status); } std::lock_guard<priority_recursive_mutex> sync(notifierMutex); // create notifier structure and add to list Notifier* notifier = new Notifier(); notifier->prev = nullptr; notifier->next = notifiers; if (notifier->next) notifier->next->prev = notifier; notifier->param = param; notifier->process = process; notifiers = notifier; return notifier; }
void stepLeft() { std::unique_lock<std::mutex> lock(mutex); for (int i = 0; i < 10; ++i) { std::cout << "left" << std::endl; isWaiting.fetch_add(1); if (isWaiting.load() % 2 != 0) { condVar.notify_one(); } else { condVar.wait(lock); } } }
Order::Order(int clientAssignedId, const std::string& account, const std::string& security, double price, int amount, Operation operation, OrderType type) : m_id(gs_id.fetch_add(1)), m_clientAssignedId(clientAssignedId), m_account(account), m_security(security), m_price(price), m_amount(amount), m_operation(operation), m_type(type), m_state(State::Unsubmitted) { }
HAL_NotifierHandle HAL_InitializeNotifier(HAL_NotifierProcessFunction process, void* param, int32_t* status) { if (!process) { *status = NULL_PARAMETER; return 0; } if (!notifierAtexitRegistered.test_and_set()) std::atexit(cleanupNotifierAtExit); if (notifierRefCount.fetch_add(1) == 0) { std::lock_guard<priority_mutex> sync(notifierInterruptMutex); // create manager and alarm if not already created if (!notifierManager) { notifierManager = std::make_unique<tInterruptManager>( 1 << kTimerInterruptNumber, false, status); notifierManager->registerHandler(alarmCallback, nullptr, status); notifierManager->enable(status); } if (!notifierAlarm) notifierAlarm.reset(tAlarm::create(status)); } std::lock_guard<priority_recursive_mutex> sync(notifierMutex); std::shared_ptr<Notifier> notifier = std::make_shared<Notifier>(); HAL_NotifierHandle handle = notifierHandles.Allocate(notifier); if (handle == HAL_kInvalidHandle) { *status = HAL_HANDLE_ERROR; return HAL_kInvalidHandle; } // create notifier structure and add to list notifier->next = notifiers; if (notifier->next) notifier->next->prev = notifier; notifier->param = param; notifier->process = process; notifier->handle = handle; notifier->threaded = false; notifiers = notifier; return handle; }
// ------------------------------------------------------------------------ void increaseGLCommandFunctionCount(int count) { m_gl_cmd_function_count.fetch_add(count); }