Lines Matching refs:std
111 std::unique_lock<std::recursive_mutex> guard(internal_mutex_); in WatchFdForNonBlockingReads()
129 std::unique_lock<std::recursive_mutex> guard(internal_mutex_); in StopWatchingFileDescriptor()
140 if (!std::atomic_exchange(&running_, false)) { in stopThread()
146 if (std::this_thread::get_id() != thread_.get_id()) { in stopThread()
154 std::unique_lock<std::recursive_mutex> guard(internal_mutex_); in stopThread()
165 if (std::atomic_exchange(&running_, true)) { in tryStartThread()
180 thread_ = std::thread([this]() { ThreadRoutine(); }); in tryStartThread()
203 std::unique_lock<std::recursive_mutex> guard(internal_mutex_); in setUpFileDescriptorSet()
227 std::vector<decltype(watched_shared_fds_)::value_type> fds; in runAppropriateCallbacks()
228 std::unique_lock<std::recursive_mutex> guard(internal_mutex_); in runAppropriateCallbacks()
242 auto read_fds = std::unique_ptr<SocketWaiter>(SocketWaiter::create()); in ThreadRoutine()
248 int retval = read_fds->wait(std::numeric_limits<int64_t>::max()); in ThreadRoutine()
268 std::atomic_bool running_{false};
269 std::thread thread_;
270 std::recursive_mutex internal_mutex_;
273 std::map<int, ReadCallback> watched_shared_fds_;
285 AsyncTaskId ExecAsync(AsyncUserId user_id, std::chrono::milliseconds delay, in ExecAsync()
287 return scheduleTask(std::make_shared<Task>( in ExecAsync()
288 std::chrono::steady_clock::now() + delay, callback, user_id)); in ExecAsync()
292 std::chrono::milliseconds delay, in ExecAsyncPeriodically()
293 std::chrono::milliseconds period, in ExecAsyncPeriodically()
295 return scheduleTask(std::make_shared<Task>( in ExecAsyncPeriodically()
296 std::chrono::steady_clock::now() + delay, period, callback, user_id)); in ExecAsyncPeriodically()
301 std::unique_lock<std::mutex> guard(internal_mutex_); in CancelAsyncTask()
307 std::unique_lock<std::mutex> guard(internal_mutex_); in CancelAsyncTasksFromUser()
319 std::unique_lock<std::mutex> guard(synchronization_mutex_); in Synchronize()
331 std::unique_lock<std::mutex> guard(internal_mutex_); in stopThread()
341 if (std::this_thread::get_id() != thread_.get_id()) { in stopThread()
354 Task(std::chrono::steady_clock::time_point time, in Task()
355 std::chrono::milliseconds period, const TaskCallback &callback, in Task()
363 Task(std::chrono::steady_clock::time_point time, in Task()
373 return std::make_pair(time, task_id) < in operator <()
374 std::make_pair(another.time, another.task_id); in operator <()
381 std::chrono::steady_clock::time_point time;
383 std::chrono::milliseconds period{};
384 std::mutex in_callback; // Taken when the callback is active
392 bool operator()(const std::shared_ptr<Task> &t1, in operator ()()
393 const std::shared_ptr<Task> &t2) const { in operator ()()
408 if (thread_.get_id() != std::this_thread::get_id()) { in cancel_task_with_lock_held()
410 const std::lock_guard<std::mutex> lock(task->in_callback); in cancel_task_with_lock_held()
421 AsyncTaskId scheduleTask(const std::shared_ptr<Task> &task) { in scheduleTask()
423 std::unique_lock<std::mutex> guard(internal_mutex_); in scheduleTask()
454 std::unique_lock<std::mutex> guard(internal_mutex_); in tryStartThread()
461 thread_ = std::thread([this]() { ThreadRoutine(); }); in tryStartThread()
472 std::shared_ptr<Task> task_p; in ThreadRoutine()
475 std::unique_lock<std::mutex> guard(internal_mutex_); in ThreadRoutine()
478 if (task_p->time < std::chrono::steady_clock::now()) { in ThreadRoutine()
494 const std::lock_guard<std::mutex> lock(task_p->in_callback); in ThreadRoutine()
498 std::unique_lock<std::mutex> guard(internal_mutex_); in ThreadRoutine()
506 std::chrono::steady_clock::time_point time = in ThreadRoutine()
517 std::thread thread_;
518 std::mutex internal_mutex_;
519 std::mutex synchronization_mutex_;
520 std::condition_variable internal_cond_var_;
524 std::map<AsyncTaskId, std::shared_ptr<Task>> tasks_by_id_;
525 std::map<AsyncUserId, std::set<AsyncTaskId>> tasks_by_user_id_;
526 std::set<std::shared_ptr<Task>, task_p_comparator> task_queue_;
560 std::chrono::milliseconds delay, in ExecAsync()
566 AsyncUserId user_id, std::chrono::milliseconds delay, in ExecAsyncPeriodically()
567 std::chrono::milliseconds period, const TaskCallback &callback) { in ExecAsyncPeriodically()