我正在尝试在Rust中使用线程之间共享一个可变对象Arc,但是我收到了这个错误:
error[E0596]: cannot borrow data in a `&` reference as mutable
--> src/main.rs:11:13
|
11 | shared_stats_clone.add_stats();
| ^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
Run Code Online (Sandbox Code Playgroud)
这是示例代码:
use std::{sync::Arc, thread};
fn main() {
let total_stats = Stats::new();
let shared_stats = Arc::new(total_stats);
let threads = 5;
for _ in 0..threads {
let mut shared_stats_clone = shared_stats.clone();
thread::spawn(move || {
shared_stats_clone.add_stats();
});
}
}
struct Stats {
hello: u32,
}
impl Stats {
pub fn new() -> Stats {
Stats { hello: 0 …Run Code Online (Sandbox Code Playgroud) 我正在使用NeHe教程在C++中学习OpenGL,但我正在尝试使用FreeImage库,而不是Glaux或SOIL.我在使用FreeImage时看到的好处是,它的最后一次更新发生在去年10月,而SOIL在5年内没有更新.我遇到的问题是我无法正确加载纹理.
这是我的代码:
static GLuint texture = 0;
if (texture == 0)
{
FIBITMAP* bitmap = FreeImage_Load(
FreeImage_GetFileType("textures/test/nehe_06.png", 0),
"textures/test/nehe_06.png");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, FreeImage_GetWidth(bitmap), FreeImage_GetHeight(bitmap),
0, GL_RGB, GL_UNSIGNED_BYTE, FreeImage_ConvertTo32Bits(bitmap));
FreeImage_Unload(bitmap);
}
Run Code Online (Sandbox Code Playgroud)
使用这个代码,我得到的纹理是错误的:它是黑色的,有彩色的点和条带,更改图像给出相同的结果,所以我假设我没有正确加载纹理.
我试图交换红色和蓝色位(读取FreeImage在BGR中加载)没有更好的结果.最后,如果我通过*FreeImage_GetBits(位图)更改*FreeImage_ConvertTo32Bits(位图)**我得到一个段错误.
我做错了什么?
我注意到每次在MAVEN中运行我的exec:java命令时都会收到此警告.
[警告]警告:现在不推荐使用killAfter.你需要它吗 ?请评论MEXEC-6.
我怎么能摆脱它?我一直在寻找它,但没有任何线索.
pom.xml中:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foodfinder</groupId>
<artifactId>food-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Food Finder client</name>
<description>The client application for the Food Finder</description>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-tools</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.razican.utils</groupId>
<artifactId>java-utils</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/Razican/FoodClient/issues</url>
</issueManagement>
<ciManagement>
<system>Travis-CI</system>
<url>https://travis-ci.org/Razican/FoodClient</url>
</ciManagement>
<repositories>
<repository>
<id>Java-Utils</id>
<url>https://raw.github.com/Razican/Java-Utils/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source> …Run Code Online (Sandbox Code Playgroud) 我有一个名为"我的项目"的存储库,它位于一个名为"framework"的框架中.它们中的每一个都有它的存储库,它们之间没有关系,每个分支和标签.我想在我的存储库中接收"框架"的更新,但只能从"默认"分支而不是其他分支.当然,我不希望在我的存储库中有"框架"标签,因为它是一个完全不同的项目.
我有Mercurial HG,我希望能够从"管理存储库"页面直接从"框架"存储库中提取更改.
此外,我只想下载最新的变更集,因为我不久前开始了我的项目.如果我可以将"框架"的默认分支重命名为我的仓库中的其他名称,例如"Framework Changesets",那将是完美的.
注意:我没有"框架"存储库的写入权限.
我试着做什么mercurial wiki说:
hg pull -f -r default "framework"
Run Code Online (Sandbox Code Playgroud)
没关系,直到我意识到我从"框架"存储库下载了所有标签,然后我从远程存储库下载了所有的变更集.此外,在TortoiseHG-> Configuration-> Synchronization中,我将"框架"存储库作为该项目的远程存储库,并从远程存储库中取出,我从该存储库获得了所有分支.
当然我无法更改默认分支名称,并更新了我的默认分支,即使我尝试使用hg convert --branchmap(但我不知道如何使用它).
我的问题有什么解决方案吗?甚至是部分解决方案?