mirror of
https://github.com/Naios/continuable.git
synced 2025-12-08 01:36:46 +08:00
basic idea of callback containers
This commit is contained in:
parent
96b4a4bfef
commit
f502803f2b
@ -49,7 +49,7 @@ namespace detail
|
||||
};
|
||||
|
||||
template<typename _CTy>
|
||||
using unwrap_callback = do_unwrap_callback<::fu::argument_type_t<_CTy>>;
|
||||
using unwrap_callback = do_unwrap_callback<::fu::argument_type_of_t<_CTy>>;
|
||||
|
||||
} // detail
|
||||
|
||||
@ -63,11 +63,11 @@ template<typename _CTy>
|
||||
using weak_callback_of_t = typename detail::unwrap_callback<_CTy>::WeakCallbackType;
|
||||
|
||||
template<typename _CTy>
|
||||
typename shared_callback_of_t<_CTy>
|
||||
inline typename shared_callback_of_t<_CTy>
|
||||
make_shared_callback(_CTy&& callback)
|
||||
{
|
||||
return std::make_shared<typename callback_of_t<_CTy>>
|
||||
(std::forward<typename callback_of_t<_CTy>>(callback));
|
||||
}
|
||||
|
||||
#endif /// _TASK_SCHEDULER_H_
|
||||
#endif /// _CALLBACK_H_
|
||||
|
||||
39
fluent++/CallbackContainer.h
Normal file
39
fluent++/CallbackContainer.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CALLBACK_CONTAINER_H_
|
||||
#define _CALLBACK_CONTAINER_H_
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Callback.h"
|
||||
|
||||
class CallbackContainer
|
||||
{
|
||||
size_t current_handle;
|
||||
|
||||
std::unordered_map<decltype(current_handle), void*> container;
|
||||
|
||||
public:
|
||||
template<typename _CTy>
|
||||
_CTy operator()(_CTy&& callback)
|
||||
{
|
||||
return callback;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /// _CALLBACK_CONTAINER_H_
|
||||
@ -114,22 +114,22 @@ namespace fu
|
||||
|
||||
/// Trait which defines the return type of the function.
|
||||
template<typename... Function>
|
||||
using return_type_t =
|
||||
using return_type_of_t =
|
||||
typename detail::select_best_unwrap<Function...>::type::return_type;
|
||||
|
||||
/// Trait which defines the argument types of the function packed in std::tuple.
|
||||
template<typename... Function>
|
||||
using argument_type_t =
|
||||
using argument_type_of_t =
|
||||
typename detail::select_best_unwrap<Function...>::type::argument_type;
|
||||
|
||||
/// Trait which defines the std::function type of the function.
|
||||
template<typename... Function>
|
||||
using function_type_t =
|
||||
using function_type_of_t =
|
||||
typename detail::select_best_unwrap<Function...>::type::function_type;
|
||||
|
||||
/// Trait which defines the function pointer type of the function.
|
||||
template<typename... Function>
|
||||
using function_ptr_t =
|
||||
using function_ptr_of_t =
|
||||
typename detail::select_best_unwrap<Function...>::type::function_ptr;
|
||||
|
||||
} // fu
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user