Artifact 3fffa6c9f2407558f209770b35fdd9976f41556126e04c22da3c356e4fc7926e:
- File
tests/objc_sync/objc_sync.m
— part of check-in
[5903c87d36]
at
2009-08-17 21:13:21
on branch trunk
— Ensure in the headers that we got the required definitions.
This prevents compiling stuff using libobjfw without objfw-config,
which could generate strange bugs. (user: js, size: 974) [annotate] [blame] [check-ins using] - File tests/objc_sync/test.m — part of check-in [81239da84f] at 2009-10-03 13:38:54 on branch trunk — Rename tests_new to tests. (user: js, size: 974) [annotate] [blame] [check-ins using]
- File tests_new/objc_sync/test.m — part of check-in [100512818f] at 2009-10-03 13:37:58 on branch trunk — Make the @synchronized test a manual test and remove old tests. (user: js, size: 974) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include "config.h" #include <stdio.h> #import "OFString.h" #import "OFThread.h" OFObject *lock; @interface MyThread: OFThread - main; @end @implementation MyThread - main { printf("[%s] Entering #1\n", [object cString]); @synchronized (lock) { printf("[%s] Entering #2\n", [object cString]); @synchronized (lock) { printf("[%s] Hello!\n", [object cString]); } printf("[%s] Left #2\n", [object cString]); } printf("[%s] Left #1\n", [object cString]); return nil; } @end int main() { lock = [[OFObject alloc] init]; MyThread *t1 = [MyThread threadWithObject: @"A"]; MyThread *t2 = [MyThread threadWithObject: @"B"]; [t1 join]; [t2 join]; return 0; }