]>
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"
29 class RGWRadosThread
{
30 class Worker
: public Thread
{
32 RGWRadosThread
*processor
;
33 ceph::mutex lock
= ceph::make_mutex("RGWRadosThread::Worker");
34 ceph::condition_variable cond
;
37 std::unique_lock l
{lock
};
41 void wait_interval(const ceph::real_clock::duration
& wait_time
) {
42 std::unique_lock l
{lock
};
43 cond
.wait_for(l
, wait_time
);
47 Worker(CephContext
*_cct
, RGWRadosThread
*_p
) : cct(_cct
), processor(_p
) {}
48 void *entry() override
;
50 std::lock_guard l
{lock
};
61 std::atomic
<bool> down_flag
= { false };
65 virtual uint64_t interval_msec() = 0;
66 virtual void stop_process() {}
68 RGWRadosThread(RGWRados
*_store
, const string
& thread_name
= "radosgw")
69 : worker(NULL
), cct(_store
->ctx()), store(_store
), thread_name(thread_name
) {}
70 virtual ~RGWRadosThread() {
74 virtual int init() { return 0; }
75 virtual int process() = 0;
77 bool going_down() { return down_flag
; }