{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2772","repository_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2772/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2772/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2772/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2772","id":144209381,"number":2772,"title":"Custom RACScheduler ","user":{"login":"Gladkov-Art","id":5657130,"avatar_url":"https://avatars.githubusercontent.com/u/5657130?v=3","gravatar_id":"","url":"https://api.github.com/users/Gladkov-Art","html_url":"https://github.com/Gladkov-Art","followers_url":"https://api.github.com/users/Gladkov-Art/followers","following_url":"https://api.github.com/users/Gladkov-Art/following{/other_user}","gists_url":"https://api.github.com/users/Gladkov-Art/gists{/gist_id}","starred_url":"https://api.github.com/users/Gladkov-Art/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gladkov-Art/subscriptions","organizations_url":"https://api.github.com/users/Gladkov-Art/orgs","repos_url":"https://api.github.com/users/Gladkov-Art/repos","events_url":"https://api.github.com/users/Gladkov-Art/events{/privacy}","received_events_url":"https://api.github.com/users/Gladkov-Art/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-29T09:32:22Z","updated_at":"2016-04-02T23:31:33Z","closed_at":null,"body":"Base on [https://robots.thoughtbot.com/reactive-core-data](https://robots.thoughtbot.com/reactive-core-data), I have create subclass of RACQueueScheduler in order to run cold signals on NSManagedObjectContext's queue. My CoreDataScheduler class looks like: \r\n\r\n```\r\n@interface CoreDataScheduler : RACQueueScheduler\r\n\r\n@property(nonatomic, readonly)NSManagedObjectContext *context;\r\n\r\n- (instancetype)initWithContext:(NSManagedObjectContext *)context;\r\n\r\n@end\r\n```\r\n\r\n```\r\n@implementation CoreDataScheduler\r\n\r\n- (instancetype)initWithContext:(NSManagedObjectContext *)context\r\n{\r\n\tif (self = [super init]) {\r\n\t\t_context = context;\r\n\t}\r\n\treturn self;\r\n}\r\n\r\n- (RACDisposable *)schedule:(void (^)(void))block\r\n{\r\n\tNSParameterAssert(block);\r\n\t\r\n\tRACDisposable *disposable = [[RACDisposable alloc] init];\r\n\t\r\n\t[self.context performBlock:^{\r\n\t\tif (disposable.disposed) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tblock();\r\n\t}];\r\n\t\r\n\treturn disposable;\r\n}\r\n```\r\nThen I'm trying to run signal on that thread (code is simplified, I've removed some logic):\r\n```\r\nRACScheduler *coreDataScheduler = [[CoreDataScheduler alloc] initWithContext:self.privateManagedObjectContext];\r\n[[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {\r\n\t\tSomeObject *object = [self.privateManagedObjectContext objectWithID:self.managedObject.objectID];\r\n\t\tNSLog(@\"%@\",object.ssid);\r\n\t\treturn nil;\r\n\t}] subscribeOn:coreDataScheduler];\r\n```\r\n\r\nSo when I try to print object's property, core data multi-threading assertions fires. That means that signal's body is executed not on `self.privateManagedObjectContext`'s queue. \r\nI have checked it, I set breakpoints inside `performBlock` in `schedule:` method of `CoreDataScheduler` and in signal's body, indeed threads were different.\r\n\r\nNeed your advice"},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/204826940","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2772#issuecomment-204826940","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2772","id":204826940,"user":{"login":"mdiep","id":1302,"avatar_url":"https://avatars.githubusercontent.com/u/1302?v=3","gravatar_id":"","url":"https://api.github.com/users/mdiep","html_url":"https://github.com/mdiep","followers_url":"https://api.github.com/users/mdiep/followers","following_url":"https://api.github.com/users/mdiep/following{/other_user}","gists_url":"https://api.github.com/users/mdiep/gists{/gist_id}","starred_url":"https://api.github.com/users/mdiep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdiep/subscriptions","organizations_url":"https://api.github.com/users/mdiep/orgs","repos_url":"https://api.github.com/users/mdiep/repos","events_url":"https://api.github.com/users/mdiep/events{/privacy}","received_events_url":"https://api.github.com/users/mdiep/received_events","type":"User","site_admin":false},"created_at":"2016-04-02T23:31:33Z","updated_at":"2016-04-02T23:31:33Z","body":"Do you have an example project that exhibits the issue?\r\n\r\nThat looks correct. And `subscribeOn:` is pretty simple, so I don't see how things could go wrong. Without seeing a project, I'm not sure how to figure out the issue."}}