Objective-C相当于Java的LinkedBlockingQueue (Objective-C equivalent of Java's LinkedBlockingQueue)
我正在使用最新的SDK开发iOS应用程序,我必须使用Objective-C实现
LinkedBlockingQueue
。我必须做类似这样的代码:
public boolean onEvent(final EventArgs e) { if (e.getClass() != this.eventType) return false; long now = android.os.SystemClock.uptimeMillis(); long diff = now - this.last; final long threadExecutionTimeMs = now - lastThreadExecution; if (executions.remainingCapacity() == 0) { executions.poll(); } executions.add(threadExecutionTimeMs); ... }
可能我可以使用
NSMutableArray
但我不知道如何模拟阻塞等。任何建议?
I'm developing an iOS application with latest SDK and I have to implement a
LinkedBlockingQueue
with Objective-C.I have to do something like this code:
public boolean onEvent(final EventArgs e) { if (e.getClass() != this.eventType) return false; long now = android.os.SystemClock.uptimeMillis(); long diff = now - this.last; final long threadExecutionTimeMs = now - lastThreadExecution; if (executions.remainingCapacity() == 0) { executions.poll(); } executions.add(threadExecutionTimeMs); ... }
Probably I can use
NSMutableArray
but I don't know how to emulate blocking, etc.Any advice?
原文:https://stackoverflow.com/questions/15762067
最满意答案
看到我的评论为真正的答案,但评论不允许正确的格式。
如果你想要使用
git
下面是一个疯狂想法的简要草图。 我知道你可以控制客户端设备,并且可以在这些设备上运行git。 您可以考虑创建原始二进制文件的哈希(例如md5 / sha1哈希)的镜像树。 然后Git会查看“hashtree”来确定什么是新的,并确保在更新git之前获取实际数据。 像这样/actual/somedir/imag1.jpg /mirror/somedir/imag1.jpg <= contains md5 hash
See my comment for the real answer, but comments don't allow for proper formatting.
Here's a quick sketch of a crazy idea if you want to go with
git
. I understand that you do have control over the client devices and that you can run git on those divices. You could consider creating a mirror tree of hashes (e.g. md5/sha1 hashes) of the original binary files. Git will then look at the "hashtree" to determine what's new, and make sure to get the actual data before updating the git. Like so/actual/somedir/imag1.jpg /mirror/somedir/imag1.jpg <= contains md5 hash
相关问答
更多-
使用Git作为更新服务器的后端,如何保持较小的版本库(Using Git as a back-end for an update server, how to keep the repository small)[2021-09-26]
看到我的评论为真正的答案,但评论不允许正确的格式。 如果你想要使用git下面是一个疯狂想法的简要草图。 我知道你可以控制客户端设备,并且可以在这些设备上运行git。 您可以考虑创建原始二进制文件的哈希(例如md5 / sha1哈希)的镜像树。 然后Git会查看“hashtree”来确定什么是新的,并确保在更新git之前获取实际数据。 像这样 /actual/somedir/imag1.jpg /mirror/somedir/imag1.jpg <= contains md5 hash See my ... -
是的,这称为自动构建或持续集成。 有许多工具可以让你这样做,但很难在不知道你的开发平台的情况下推荐一个( TeamCity ,我最喜欢的,与git和许多开发平台一起工作)。 根据您的网站的用途,在每次提交时将代码推送到生产中通常存在风险。 通常这个过程比那个更受控制。 Yes, this is called an automated build, or Continuous Integration. There are many tools that allow you to do this, but it ...
-
行git remote add foo myUser@git.mydomain.com:foo.git假定目录foo.git位于myUser用户的主目录中。 你使用绝对路径好得多,例如git remote add foo myUser@git.mydomain.com:/home/gitrepos/foo.git 如果您在共享服务器上,则可以通过执行以下命令来检查您的主路径: echo $HOME 就我而言,这产生了: 家用/ U / 01234 / 如果我已将自己的存储库存储在主路径的www / git ...
-
只有当所有测试都通过时,Git主存储库更新,怎么办?(Git main repository update only if all tests pass, how to do?)[2023-12-24]
CI服务器可以为您完成,但一个简单的脚本也可以做到这一点。 David Gageot前段时间在他的博客中介绍了一种非常简单的私人建筑解决方案(想法是在推送远程服务器之前在辅助本地回购库上构建测试): http://blog.javabien.net/tag/git/page/2/ 不幸的是,它是用法语编写的,但您仍然可以看看用于执行此操作的脚本: #!/bin/bash if [ 0 -eq `git remote -v | grep -c push` ]; then REMOTE_REPO=`gi ... -
你要做的事情有点棘手,因为你不能推送到远程分支,如果那里有任何你没有本地的提交 - 冲突与否。 如果你对此感觉不错,那么你就是在正确的轨道上。 我假设您将上面的脚本设置为后接收挂钩? 您只需将其设置为预接收挂钩 ,如果有修改则返回非零值。 您可能还希望向用户回显错误消息,告诉他发生了什么。 如果发生这种情况,推送将失败并且用户必须在他可以推动之前拉动(因为推动不再是快进)。 但是, 在检查更改之前,为什么要进行结账? What you are trying to do is kind of tricky, ...
-
通过url从git更新服务器(Update server from git by url)[2022-05-12]
由于每个人都在为你提到的同一个git repo工作,我认为你几乎已经设置了git服务器 。 这意味着你的本地出处应该指向git@192.168.1.2:myproject / myproject.git。 您可以使用此功能从任何远程客户端进行推送/拉取(您需要使用公共IP并为公共网络设置适当的防火墙)。 您只需要在远程客户端上安装Git,使用该地址作为远程源,克隆回购,并随时随地取出。 如果你喜欢,你可以安排/ cron。 您也可以像使用其他shell命令一样使用PHP来执行此命令。 既然你提到了URL,你 ... -
Git有一个中央存储库(Git with a central repository)[2022-11-16]
是的,那是对的。 还有一个你可能想要设置的选项: core.sharedRepository告诉Git,当它创建其他目录时,它应该将它们chgrp到该组。 关于如何在http://criticallog.thornet.net/2010/01/07/sharing-your-git-repository/设置它有一个很好的写作 Yep, that's about right. There's one more option you'd probably want to set: core.sharedRep ... -
您必须进行结帐,然后进行比较以确定哪些文件已更改,然后通过提交和推送将它们添加到存储库中。 然后将目录设为只读,以防止将来发生此类事件。 You'd have to do a checkout, then do a comparison in order to determine what files have changed, then add them into the repository by doing a commit and push. And then make the directorie ...
-
Git是分布式的,因此您描述的工作流程本质上就是Git的工作原理。 我们首先考虑您不想再提交更改。 然后你可以git clone远程服务器, git remote add你的私人服务器并推送到它。 当上游有你想要的新东西时, git pull从中git pull出来,当你有任何新东西时, git push送到你的私人服务器。 在此工作流程中,私有服务器上的提交和公共服务器上的提交是相同的(特别是相同的sha1),但是您的私有服务器有一些公共服务器没有的提交。 在第一个和git remote add使用git ...
-
这告诉你的是,你的裸origin存储库中没有master分支,因为它是空的。 因此,它无法找到您想要更新的分支,并且默认情况下它不会盲目地创建新分支(如果它是一个拼写错误或其他东西)。 你可能需要第一次使用git push -f origin master 。 一旦在origin有一个master分支,正常的git push应该可以正常工作。 或者,您可以首先创建您的工作存储库,其中至少有一个提交,然后git clone --bare它放入您的git-daemon位置,但是您将要删除裸存储库中的origin ...