]>
git.proxmox.com Git - ceph.git/blob - ceph/src/msg/QueueStrategy.cc
0ce279b31e9f1055abd6b79545a53df6d76a840e
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 CohortFS, LLC
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "QueueStrategy.h"
16 #define dout_subsys ceph_subsys_ms
17 #include "common/debug.h"
19 QueueStrategy::QueueStrategy(int _n_threads
)
20 : lock("QueueStrategy::lock"),
21 n_threads(_n_threads
),
28 void QueueStrategy::ds_dispatch(Message
*m
) {
29 msgr
->ms_fast_preprocess(m
);
30 if (msgr
->ms_can_fast_dispatch(m
)) {
31 msgr
->ms_fast_dispatch(m
);
36 if (disp_threads
.size()) {
37 if (! disp_threads
.empty()) {
38 QSThread
*thrd
= &disp_threads
.front();
39 disp_threads
.pop_front();
46 void QueueStrategy::entry(QSThread
*thrd
)
52 if (! mqueue
.empty()) {
53 m
= &(mqueue
.front());
60 disp_threads
.push_front(*thrd
);
61 thrd
->cond
.Wait(lock
);
69 get_messenger()->ms_deliver_dispatch(m
);
73 void QueueStrategy::shutdown()
78 while (disp_threads
.size()) {
79 thrd
= &(disp_threads
.front());
80 disp_threads
.pop_front();
86 void QueueStrategy::wait()
91 while (disp_threads
.size()) {
92 thrd
= &(disp_threads
.front());
93 disp_threads
.pop_front();
96 // join outside of lock
104 void QueueStrategy::start()
109 for (int ix
= 0; ix
< n_threads
; ++ix
) {
110 string thread_name
= "ms_xio_qs_";
111 thread_name
.append(std::to_string(ix
));
112 thrd
= new QSThread(this);
113 thrd
->create(thread_name
.c_str());