]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_worker.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2019 Red Hat, Inc.
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
21 #include "common/Thread.h"
22 #include "common/ceph_mutex.h"
23 #include "include/common_fwd.h"
27 class RGWRadosThread
{
28 class Worker
: public Thread
, public DoutPrefixProvider
{
30 RGWRadosThread
*processor
;
31 ceph::mutex lock
= ceph::make_mutex("RGWRadosThread::Worker");
32 ceph::condition_variable cond
;
35 std::unique_lock l
{lock
};
39 void wait_interval(const ceph::real_clock::duration
& wait_time
) {
40 std::unique_lock l
{lock
};
41 cond
.wait_for(l
, wait_time
);
45 Worker(CephContext
*_cct
, RGWRadosThread
*_p
) : cct(_cct
), processor(_p
) {}
46 void *entry() override
;
48 std::lock_guard l
{lock
};
52 CephContext
*get_cct() const { return cct
; }
53 unsigned get_subsys() const { return ceph_subsys_rgw
; }
54 std::ostream
& gen_prefix(std::ostream
& out
) const { return out
<< "rgw rados thread: "; }
64 std::atomic
<bool> down_flag
= { false };
66 std::string thread_name
;
68 virtual uint64_t interval_msec() = 0;
69 virtual void stop_process() {}
71 RGWRadosThread(RGWRados
*_store
, const std::string
& thread_name
= "radosgw")
72 : worker(NULL
), cct(_store
->ctx()), store(_store
), thread_name(thread_name
) {}
73 virtual ~RGWRadosThread() {
77 virtual int init(const DoutPrefixProvider
*dpp
) { return 0; }
78 virtual int process(const DoutPrefixProvider
*dpp
) = 0;
80 bool going_down() { return down_flag
; }