草庐IT

dispatch_semaphore_dispose

全部标签

ruby-on-rails - 如何让 redis-semaphore 队列 "task_3"直到 "task_1"和 "task_2"已解锁(rails)?

我的情况:在我的Rails应用程序中,我使用redis-semaphore来确保重复作业不会相互干扰。我用这些代码行来完成:s1=Redis::Semaphore.new(:task_1,connection:"localhost")ifs1.lock(-1)begin#Performtask_1rescue=>eputseensures1.unlockendend这一切都很好,所以如果还没有:task_1正在进行中,:task_1将被排队。当已经运行的:task_1完成并解锁时,排队的:task_1将开始......我的问题:如果我正在运行2个不同的任务-让我们称它们为:task_1

c# - .Net - Redis 缓存 "object disposed exception"

在调试和本地测试我的应用程序时,我时不时会收到与System.ObjectDisposedException关联的"SocketManger.cs"notfound。我得到这个是因为在异常设置面板上我完全检查了CommonLanguageRuntimeExceptions。我无法深入了解这个问题,因为我一直按F10,希望有那么一刻,调试器会带我调用正在尝试执行的读/写操作在已处置的对象上执行。但那一刻永远不会到来......我可以在调用堆栈窗口中看到我正在堆栈上,到达[ExternalCode]但我就是无法返回到我的代码。..由于这个问题经常发生,我需要完成它,因为这会破坏我的缓存或不

django - 将请求从一个 uwsgi 分派(dispatch)到另一个运行 Django Channels 的 uwsgi 实例

我目前正在使用Djangochannel进行websocket通信。我阅读了这篇文章,它指出我应该将项目拆分为两个uwsgi实例。它指出“Web服务器负责将正常请求分派(dispatch)到一个uWSGI实例,将WebSocket请求分派(dispatch)到另一个”现在我有两个uwsgi实例在运行。这就是我运行两者的方式。这个uwsgi处理正常的django站点请求uwsgi--virtualenv/home/ec2-user/MyProjVenv--socket/home/ec2-user/MyProjVenv/MyProjWeb/site1.socket--chmod-socke

ios - iOS 中的 JSON 请求 - 使用 Grand Central Dispatch 或 NSURLConnection

我看到了一些关于在iOS中发出JSON请求的教程,其中许多使用NSURLConnection列出了类似这样的内容:-(void)connection:(NSURLConnection*)connectiondidReceiveResponse:(NSURLResponse*)response{[self.responseDatasetLength:0];}-(void)connection:(NSURLConnection*)connectiondidReceiveData:(NSData*)data{[self.responseDataappendData:data];}-(void

ios - 什么是 dispatch_queue_create 中的队列属性

在Apple的示例代码中,AVCam-iOS:UsingAVFoundationtoCaptureImagesandMovies,我注意到以下一行://Communicatewiththesessionandothersessionobjectsonthisqueue.self.sessionQueue=dispatch_queue_create("sessionqueue",DISPATCH_QUEUE_SERIAL);我想知道第二个参数是关于什么的,除了DISPATCH_QUEUE_SERIAL我们还有哪些其他选项?令人困惑的是,在其他Apple文档中,它说第二个参数是保留的,应该

ios - 当方法重新运行时,在方法中循环 dispatch_after 会导致许多同时调度

我正在创建一个简单的游戏。我有以下代码:-(void)doStuff{doubledelayInSeconds=[NSNumberrandomFloatBetweenLowerBound:0.8fupperBound:2.6f];//OwncategoryonNSNumberreturnsrandomfloat.dispatch_time_tpopTime=dispatch_time(DISPATCH_TIME_NOW,(int64_t)(delayInSeconds*NSEC_PER_SEC));dispatch_after(popTime,dispatch_get_main_que

ios - 在 dispatch_once(&onceToken, ^{

+(Service*)sharedInstance{staticLocationService*instance=nil;staticdispatch_once_tonceToken;dispatch_once(&onceToken,^{我正在使用上面显示的代码在我的应用程序中创建服务的单例实例。这是从“AppDelegateapplication:willFinishLaunchingWithOptions:”调用的。对于大多数用户来说,这段代码工作正常。但是对于2个用户,应用程序在“dispatch_once(&onceToken,^{”行崩溃。他们删除了该应用程序并重新安装了它。

iphone - 这段代码中dispatch_after方法是并发执行的吗?

inttotal=0;//theseareglobals..BOOLdispatchCalled=NO;//-(void)callDispatch{dispatch_after(dispatch_time(DISPATCH_TIME_NOW,0.3*NSEC_PER_SEC),dispatch_get_current_queue(),^{dispatchCalled=YES;NSLog(@"Total,after300ms,is%i",total);});}-(void)play//thisismy"main"method..{NSLog(@"appstartsrunning");[s

iOS TableView 滞后问题,我正在使用分派(dispatch)和保存缓存

-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{TableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:@"TableViewCell"forIndexPath:indexPath];cell.tag=indexPath.row;//cell.imageView.image=nil;//RoundedRectforcellimageCALayer*cellImageLay

iphone - 使用图层和 Grand Central Dispatch 渲染 UIButtons 的最快方法?

我有一个包含30个UIButton的网格,甚至可能更多,它们被子类化以使用层进行渲染:一个基本CALayer、一个CAShapeLayer、一个CAGradientLayer和一个CATextLayer。我试图在加载相应的xib文件时尽量减少渲染/显示按钮所需的总时间。如果我在viewDidLoad中简单地依次设置每个按钮,View出现所需的时间大约为5-6秒,这显然太多了。为了加快按钮设置速度,我按如下方式使用GrandCentralDispatch。在viewDidLoad中,我在全局队列上使用dispatch_async设置每个按钮层(将形状层和渐变层添加到基础层),以便按钮可以