File: evabase.cc

package info (click to toggle)
apt-cacher-ng 3.3.1-2~bpo10+1
  • links: PTS, VCS
  • area: main
  • in suites: buster-backports
  • size: 2,040 kB
  • sloc: cpp: 17,564; sh: 553; ansic: 401; perl: 377; makefile: 126
file content (46 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
/*
 * evabase.cc
 *
 *  Created on: 14.03.2019
 *      Author: EB
 */

#include "evabase.h"
#include "evasocket.h"

#include "meta.h"
#include <event.h>

namespace acng
{

std::shared_ptr<evabase> evabase::instance;
std::atomic<bool> evabase::in_shutdown = ATOMIC_VAR_INIT(false);

evabase::evabase() : base (event_base_new())
{
}

evabase::~evabase()
{
	event_base_free(base);
}

void acng::evabase::register_activity(socket_activity_base* p)
{
	m_weak_ref_users.insert(p);
}

void acng::evabase::unregister_activity(socket_activity_base* p)
{
	m_weak_ref_users.erase(p);
}

void evabase::invoke_shutdown_activities()
{
	auto snapshot = m_weak_ref_users;
	for(const auto& opfer: snapshot)
		if(opfer) opfer->invoke_shutdown();
}

}