Stxxl  1.4.0
include/stxxl/bits/io/request_with_state.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  include/stxxl/bits/io/request_with_state.h
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00007  *  Copyright (C) 2009 Johannes Singler <singler@ira.uka.de>
00008  *
00009  *  Distributed under the Boost Software License, Version 1.0.
00010  *  (See accompanying file LICENSE_1_0.txt or copy at
00011  *  http://www.boost.org/LICENSE_1_0.txt)
00012  **************************************************************************/
00013 
00014 #ifndef STXXL_IO__REQUEST_WITH_STATE_H_
00015 #define STXXL_IO__REQUEST_WITH_STATE_H_
00016 
00017 #include <stxxl/bits/common/state.h>
00018 #include <stxxl/bits/io/request.h>
00019 #include <stxxl/bits/io/request_with_waiters.h>
00020 
00021 
00022 __STXXL_BEGIN_NAMESPACE
00023 
00024 //! \addtogroup fileimpl
00025 //! \{
00026 
00027 //! \brief Request with completion state.
00028 class request_with_state : public request, public request_with_waiters
00029 {
00030 protected:
00031     //! states of request
00032     //! OP - operating, DONE - request served, READY2DIE - can be destroyed
00033     enum request_state { OP = 0, DONE = 1, READY2DIE = 2 };
00034 
00035     state<request_state> _state;
00036 
00037 protected:
00038     request_with_state(
00039         const completion_handler & on_cmpl,
00040         file * f,
00041         void * buf,
00042         offset_type off,
00043         size_type b,
00044         request_type t) :
00045         request(on_cmpl, f, buf, off, b, t),
00046         _state(OP)
00047     { }
00048 
00049 public:
00050     virtual ~request_with_state();
00051     void wait(bool measure_time = true);
00052     bool poll();
00053     bool cancel();
00054 };
00055 
00056 //! \}
00057 
00058 __STXXL_END_NAMESPACE
00059 
00060 #endif // !STXXL_IO__REQUEST_WITH_STATE_H_
00061 // vim: et:ts=4:sw=4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines