void Handle::setError(const scy::Error& err) { // if (_error == err) return; assertThread(); _error = err; onError(err); }
//this function isn't thread safe void Thread::start(void *arg) { if(m_started) { LOG(Log::WARN)<<"start a thread more than one time"; return ; } m_started = true; m_arg = arg; int ret = pthread_create(&m_thread_id, nullptr, Thread::realStartThread, this); assertThread("create thread", ret); }
void Handle::close() { assertThread(); if (!_closed) { if (_ptr && !uv_is_closing(_ptr)) { uv_close(_ptr, [](uv_handle_t* handle) { delete handle; }); } // We no longer know about the handle. // The handle pointer will be deleted on afterClose. _ptr = nullptr; _closed = true; // Send the local onClose to run final callbacks. onClose(); } }
uv_handle_t* Handle::ptr() const { assertThread(); return _ptr; }
uv_loop_t* Handle::loop() const { assertThread(); return _loop; }
void Handle::setLoop(uv_loop_t* loop) { assertThread(); assert(_ptr == nullptr && "loop must be set before handle"); _loop = loop; }