summaryrefslogtreecommitdiff
path: root/src/cam/event_loop.cpp
blob: e8ab861790ed05d27ea149748e7783f0d3be73f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event_loop.cpp - cam - Event loop
 */

#include <libcamera/event_dispatcher.h>

#include "event_loop.h"

using namespace libcamera;

EventLoop::EventLoop(EventDispatcher *dispatcher)
	: dispatcher_(dispatcher)
{
}

EventLoop::~EventLoop()
{
}

int EventLoop::exec()
{
	exitCode_ = -1;
	exit_.store(false, std::memory_order_release);

	while (!exit_.load(std::memory_order_acquire))
		dispatcher_->processEvents();

	return exitCode_;
}

void EventLoop::exit(int code)
{
	exitCode_ = code;
	exit_.store(true, std::memory_order_release);
	dispatcher_->interrupt();
}
t.zx2c4.com/cgit/about/'>cgit v1.2.1 (git 2.18.0) at 2024-12-21 05:21:52 +0000