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