CARLA
 
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | Private 属性 | 所有成员列表
carla::RecurrentSharedFuture< T > 模板类 参考

这个类类似于共享未来(shared future)的使用方式,但是它的值可以被设置任意次数的值。 未来设计模式的核心思想是异步调用。 Future接口象征着异步执行任务的结果即执行一个耗时任务完全可以另起一个线程执行,然后此时我们可以去做其他事情,做完其他事情我们再调用Future.get()方法获取结果即可。 对于未来模式来说,它无法立即返回你需要的数据,但是它会返回一个契约,将来你可以凭借这个契约去获取你需要的信息。 服务程序并不等数据处理完成便立即返回客户端一个伪造的数据(如:商品的订单,而不是商品本身); 在完成其他业务处理后,最后再使用返回比较慢的Future数据。 参考:https://blog.csdn.net/weixin_43816711/article/details/125664746 更多...

#include <RecurrentSharedFuture.h>

+ 类 carla::RecurrentSharedFuture< T > 继承关系图:
+ carla::RecurrentSharedFuture< T > 的协作图:

struct  mapped_type
 

Public 类型

using SharedException = detail::SharedException
 

Public 成员函数

template<typename ExceptionT >
void SetException (ExceptionT &&exception)
 设置一个异常,这个异常将会被抛给所有正在等待的线程
 
template<typename T2 >
void SetValue (const T2 &value)
 设置值并通知所有等待的线程
 
boost::optional< T > WaitFor (time_duration timeout)
 等待直到下一个值被设置。任意数量的线程可以同时等待。
 

Private 属性

std::condition_variable _cv
 
std::map< const char *, mapped_type_map
 
std::mutex _mutex
 

详细描述

template<typename T>
class carla::RecurrentSharedFuture< T >

这个类类似于共享未来(shared future)的使用方式,但是它的值可以被设置任意次数的值。 未来设计模式的核心思想是异步调用。 Future接口象征着异步执行任务的结果即执行一个耗时任务完全可以另起一个线程执行,然后此时我们可以去做其他事情,做完其他事情我们再调用Future.get()方法获取结果即可。 对于未来模式来说,它无法立即返回你需要的数据,但是它会返回一个契约,将来你可以凭借这个契约去获取你需要的信息。 服务程序并不等数据处理完成便立即返回客户端一个伪造的数据(如:商品的订单,而不是商品本身); 在完成其他业务处理后,最后再使用返回比较慢的Future数据。 参考:https://blog.csdn.net/weixin_43816711/article/details/125664746

在文件 RecurrentSharedFuture.h48 行定义.

成员类型定义说明

◆ SharedException

template<typename T >
using carla::RecurrentSharedFuture< T >::SharedException = detail::SharedException

在文件 RecurrentSharedFuture.h51 行定义.

成员函数说明

◆ SetException()

template<typename T >
template<typename ExceptionT >
void carla::RecurrentSharedFuture< T >::SetException ( ExceptionT && exception)

设置一个异常,这个异常将会被抛给所有正在等待的线程

注解
The exception 将被存储在一个名为 SharedException 的共享对象上,并且会作为这样的异常被抛出 定义一个模板类,该类可以处理并存储特定类型的异常

在文件 RecurrentSharedFuture.h148 行定义.

被这些函数引用 TEST().

+ 这是这个函数的调用关系图:

◆ SetValue()

template<typename T >
template<typename T2 >
void carla::RecurrentSharedFuture< T >::SetValue ( const T2 & value)

设置值并通知所有等待的线程

在文件 RecurrentSharedFuture.h137 行定义.

被这些函数引用 TEST().

+ 这是这个函数的调用关系图:

◆ WaitFor()

template<typename T >
boost::optional< T > carla::RecurrentSharedFuture< T >::WaitFor ( time_duration timeout)

等待直到下一个值被设置。任意数量的线程可以同时等待。

返回
如果达到超时时间timeout仍然未获得结果,则返回空的 boost::optional boost::optional 即可选返回值,是函数的返回值,可能并不总是返回结果。

在文件 RecurrentSharedFuture.h117 行定义.

引用了 carla::detail::thread_tag, carla::throw_exception() , 以及 carla::time_duration::to_chrono().

被这些函数引用 TEST(), TEST() , 以及 TEST().

+ 函数调用图:
+ 这是这个函数的调用关系图:

类成员变量说明

◆ _cv

template<typename T >
std::condition_variable carla::RecurrentSharedFuture< T >::_cv
private

在文件 RecurrentSharedFuture.h73 行定义.

◆ _map

template<typename T >
std::map<const char *, mapped_type> carla::RecurrentSharedFuture< T >::_map
private

在文件 RecurrentSharedFuture.h80 行定义.

◆ _mutex

template<typename T >
std::mutex carla::RecurrentSharedFuture< T >::_mutex
private

在文件 RecurrentSharedFuture.h71 行定义.


该类的文档由以下文件生成: