14ff1a49eSDaniel Owen/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
24ff1a49eSDaniel Owen/*
34ff1a49eSDaniel Owen *     Copyright 2016 Couchbase, Inc
44ff1a49eSDaniel Owen *
54ff1a49eSDaniel Owen *   Licensed under the Apache License, Version 2.0 (the "License");
64ff1a49eSDaniel Owen *   you may not use this file except in compliance with the License.
74ff1a49eSDaniel Owen *   You may obtain a copy of the License at
84ff1a49eSDaniel Owen *
94ff1a49eSDaniel Owen *       http://www.apache.org/licenses/LICENSE-2.0
104ff1a49eSDaniel Owen *
114ff1a49eSDaniel Owen *   Unless required by applicable law or agreed to in writing, software
124ff1a49eSDaniel Owen *   distributed under the License is distributed on an "AS IS" BASIS,
134ff1a49eSDaniel Owen *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144ff1a49eSDaniel Owen *   See the License for the specific language governing permissions and
154ff1a49eSDaniel Owen *   limitations under the License.
164ff1a49eSDaniel Owen */
174ff1a49eSDaniel Owen
184ff1a49eSDaniel Owen#pragma once
194ff1a49eSDaniel Owen
204ff1a49eSDaniel Owen#include "buckets.h"
214ff1a49eSDaniel Owen#include "connection.h"
22c7abf941STrond Norbye#include "memcached.h"
234ff1a49eSDaniel Owen#include "memcached/server_api.h"
244ff1a49eSDaniel Owen#include "task.h"
254ff1a49eSDaniel Owen
264ff1a49eSDaniel Owen#include <string>
274ff1a49eSDaniel Owen
284ff1a49eSDaniel Owen
294ff1a49eSDaniel Owenclass McbpDestroyBucketTask : public Task {
304ff1a49eSDaniel Owenpublic:
314ff1a49eSDaniel Owen    McbpDestroyBucketTask(const std::string& name_,
324ff1a49eSDaniel Owen                          bool force_,
331f38beadSTrond Norbye                          Cookie* cookie_)
341f38beadSTrond Norbye        : thread(name_, force_, cookie_, this) {
354ff1a49eSDaniel Owen    }
364ff1a49eSDaniel Owen
374ff1a49eSDaniel Owen    // start the bucket deletion
384ff1a49eSDaniel Owen    // May throw std::bad_alloc if we're failing to start the thread
394ff1a49eSDaniel Owen    void start() {
404ff1a49eSDaniel Owen        thread.start();
414ff1a49eSDaniel Owen    }
424ff1a49eSDaniel Owen
43fbd739aeSTrond Norbye    Status execute() override {
44e4971becSWill Gardner        return Status::Finished;
454ff1a49eSDaniel Owen    }
464ff1a49eSDaniel Owen
47fbd739aeSTrond Norbye    void notifyExecutionComplete() override {
481f38beadSTrond Norbye        const auto* cookie = thread.getCookie();
491f38beadSTrond Norbye        if (cookie != nullptr) {
501f38beadSTrond Norbye            notify_io_complete(
511f38beadSTrond Norbye                static_cast<const void*>(cookie), thread.getResult());
524ff1a49eSDaniel Owen        }
534ff1a49eSDaniel Owen    }
544ff1a49eSDaniel Owen
551f38beadSTrond Norbyeprotected:
564ff1a49eSDaniel Owen    DestroyBucketThread thread;
574ff1a49eSDaniel Owen};