首页 \ 问答 \ Objective-C相当于Java的LinkedBlockingQueue (Objective-C equivalent of Java's LinkedBlockingQueue)

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
更新时间:2023-08-27 17:08

最满意答案

看到我的评论为真正的答案,但评论不允许正确的格式。

如果你想要使用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下面是一个疯狂想法的简要草图。 我知道你可以控制客户端设备,并且可以在这些设备上运行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 ...
  • 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, ...
  • 由于每个人都在为你提到的同一个git repo工作,我认为你几乎已经设置了git服务器 。 这意味着你的本地出处应该指向git@192.168.1.2:myproject / myproject.git。 您可以使用此功能从任何远程客户端进行推送/拉取(您需要使用公共IP并为公共网络设置适当的防火墙)。 您只需要在远程客户端上安装Git,使用该地址作为远程源,克隆回购,并随时随地取出。 如果你喜欢,你可以安排/ cron。 您也可以像使用其他shell命令一样使用PHP来执行此命令。 既然你提到了URL,你 ...
  • 是的,那是对的。 还有一个你可能想要设置的选项: 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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。