ObjFW  Check-in [3fbc337547]

Overview
Comment:Add +[sleepUntilDate:] to OFDate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3fbc337547de6e73cb27210500c888e1e3bcb5e662af96b5db06d88044cd1d58
User & Date: js on 2011-01-11 19:59:47
Other Links: manifest | tags
Context
2011-01-11
20:01
Fix a documentation bug in OFDate. check-in: 904971ac2b user: js tags: trunk
19:59
Add +[sleepUntilDate:] to OFDate. check-in: 3fbc337547 user: js tags: trunk
19:46
Windows calls it WSAENOTCONN. check-in: e8c1757fb8 user: js tags: trunk
Changes

Modified src/OFThread.h from [c73592c469] to [0e4696b05c].

15
16
17
18
19
20
21


22
23
24
25
26
27
28
 */

#import "OFObject.h"
#import "OFList.h"

#import "threading.h"



/**
 * \brief A class for Thread Local Storage keys.
 */
@interface OFTLSKey: OFObject
{
@public
	of_tlskey_t key;







>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 */

#import "OFObject.h"
#import "OFList.h"

#import "threading.h"

@class OFDate;

/**
 * \brief A class for Thread Local Storage keys.
 */
@interface OFTLSKey: OFObject
{
@public
	of_tlskey_t key;
112
113
114
115
116
117
118





119
120
121
122
123
124
125
+ (OFThread*)currentThread;

/**
 * Suspends execution of the current thread for N milliseconds.
 */
+ (void)sleepForNMilliseconds: (unsigned int)msecs;






/**
 * Yields a processor voluntarily and moves the thread at the end of the queue
 * for its priority.
 */
+ (void)yield;

/**







>
>
>
>
>







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
+ (OFThread*)currentThread;

/**
 * Suspends execution of the current thread for N milliseconds.
 */
+ (void)sleepForNMilliseconds: (unsigned int)msecs;

/**
 * Suspends execution of the current thread until the specified date.
 */
+ (void)sleepUntilDate: (OFDate*)date;

/**
 * Yields a processor voluntarily and moves the thread at the end of the queue
 * for its priority.
 */
+ (void)yield;

/**

Modified src/OFThread.m from [5063c8614f] to [8e9159db32].

21
22
23
24
25
26
27

28
29
30
31
32
33
34
# include <sched.h>
#else
# include <windows.h>
#endif

#import "OFThread.h"
#import "OFList.h"

#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#import "threading.h"

static OFList *tlskeys;
static of_tlskey_t thread_self;







>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# include <sched.h>
#else
# include <windows.h>
#endif

#import "OFThread.h"
#import "OFList.h"
#import "OFDate.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#import "threading.h"

static OFList *tlskeys;
static of_tlskey_t thread_self;
99
100
101
102
103
104
105





















106
107
108
109
110
111
112
{
#ifndef _WIN32
	usleep(msecs * 1000);
#else
	Sleep(msecs);
#endif
}






















+ (void)yield
{
#ifndef _WIN32
	sched_yield();
#else
	Sleep(0);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
#ifndef _WIN32
	usleep(msecs * 1000);
#else
	Sleep(msecs);
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDate *now = [OFDate date];
	int64_t sec;
	uint32_t usec;

	if ((sec = [date timeIntervalSinceDate: now]) < 0)
		@throw [OFOutOfRangeException newWithClass: self];

	usec = [date microsecondsOfTimeIntervalSinceDate: now];

	[pool release];

#ifndef _WIN32
	usleep(sec * 1000000 + usec);
#else
	Sleep(sec * 1000 + usec / 1000);
#endif
}

+ (void)yield
{
#ifndef _WIN32
	sched_yield();
#else
	Sleep(0);