Esempio n. 1
0
semaphore::semaphore(size_type released /*=0*/, size_type max_count /*=size_type(-1)*/)
{
    THOR_COMPILETIME_ASSERT(MAX_LONG > 0 && (MAX_LONG + 1) < 0, InvalidAssumption);
    LONG maximumCount = (LONG)thor::math::clamp<size_type>(max_count, 0U, MAX_LONG);
    LONG initialCount = (LONG)thor::math::clamp<size_type>(released,  0U, maximumCount);
    handle_ = ::CreateSemaphoreW(NULL, initialCount, maximumCount, NULL);
    THOR_ASSERT(handle_);
}
Esempio n. 2
0
bool thread::start(bool start_suspended /*=false*/)
{
    if (handle_ == (void*)INVALID_HANDLE_VALUE)
    {
        add_ref();
        stop_requested_ = 0;
        THOR_ASSERT(stack_size_ <= UINT_MAX);
        handle_ = (void*)_beginthreadex(0, (unsigned int)stack_size_, &internal::thread_base::start_thread_proc, static_cast<internal::thread_base*>(this), start_suspended ? CREATE_SUSPENDED : 0, &thread_id_.thread_id_);
        if (handle_ != (void*)INVALID_HANDLE_VALUE)
        {
            debug::set_thread_name(name_.c_str(), thread_id_);
            if (start_suspended) ++suspend_count_;
            return true;
        }
    }
    return false;
}
Esempio n. 3
0
void ThStringUtilities::ToWideString(ThF64 val, ThWchar* result, ThSize bufSize)
{
	if( swprintf(result, bufSize, L"%lf", val) < 0 )
		THOR_ASSERT(0, "Buffer is too small");
}
Esempio n. 4
0
void ThStringUtilities::ToString(ThU64 val, ThChar* result, ThSize bufSize)
{
	if( sprintf(result, "%llu", val) < 0 )
		THOR_ASSERT(0, "Buffer is too small");
}