]> git.saurik.com Git - apple/libc.git/blame - pthreads/pthread_workqueue.h
Libc-763.13.tar.gz
[apple/libc.git] / pthreads / pthread_workqueue.h
CommitLineData
224c7076
A
1/*
2 * Copyright (c) 2007 Apple, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* pthread workqueue defns */
24
25#ifndef _POSIX_PTHREAD_WORKQUEUE_H
26#define _POSIX_PTHREAD_WORKQUEUE_H
27
28#include <sys/cdefs.h>
29#include <pthread.h>
1f2f436a 30#include <Availability.h>
224c7076
A
31
32#define __PTHREAD_WORKQ_SIZE__ 128
33#define __PTHREAD_WORKQ_ATTR_SIZE__ 60
34
34e8f829
A
35#define PTHREAD_WORKQUEUE_SIG 0xBEBEBEBE
36#define PTHREAD_WORKQUEUE_ATTR_SIG 0xBEBEBEBE
224c7076
A
37
38#ifndef __POSIX_LIB__
39typedef struct { unsigned int sig; char opaque[__PTHREAD_WORKQ_SIZE__];} *pthread_workqueue_t;
40typedef struct { unsigned int sig; char opaque[__PTHREAD_WORKQ_ATTR_SIZE__]; } pthread_workqueue_attr_t;
41#endif
42typedef void * pthread_workitem_handle_t;
34e8f829
A
43/* Kernel expected target concurrency of the workqueue clients for the three priority queues */
44
1f2f436a
A
45#define WORKQ_HIGH_PRIOQUEUE 0 /* high priority queue */
46#define WORKQ_DEFAULT_PRIOQUEUE 1 /* default priority queue */
47#define WORKQ_LOW_PRIOQUEUE 2 /* low priority queue */
48#define WORKQ_BG_PRIOQUEUE 3 /* background priority queue */
34e8f829 49
1f2f436a 50#define WORKQ_NUM_PRIOQUEUE 4
34e8f829
A
51
52extern __int32_t workq_targetconc[WORKQ_NUM_PRIOQUEUE];
224c7076
A
53
54__BEGIN_DECLS
1f2f436a
A
55int pthread_workqueue_init_np(void) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
56int pthread_workqueue_attr_init_np(pthread_workqueue_attr_t * attr) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
57int pthread_workqueue_attr_destroy_np(pthread_workqueue_attr_t * attr) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
58int pthread_workqueue_attr_getqueuepriority_np(const pthread_workqueue_attr_t * attr, int * qprio) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
34e8f829 59/* WORKQ_HIGH/DEFAULT/LOW_PRIOQUEUE are the only valid values */
1f2f436a
A
60int pthread_workqueue_attr_setqueuepriority_np(pthread_workqueue_attr_t * attr, int qprio) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
61int pthread_workqueue_attr_getovercommit_np(const pthread_workqueue_attr_t * attr, int * ocommp) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
62int pthread_workqueue_attr_setovercommit_np(pthread_workqueue_attr_t * attr, int ocomm) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
224c7076 63
224c7076 64
1f2f436a
A
65int pthread_workqueue_create_np(pthread_workqueue_t * workqp, const pthread_workqueue_attr_t * attr) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
66int pthread_workqueue_additem_np(pthread_workqueue_t workq, void ( *workitem_func)(void *), void * workitem_arg, pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
34e8f829 67/* If the queue value is WORKQ_NUM_PRIOQUEUE, the request for concurrency is for all queues */
1f2f436a
A
68int pthread_workqueue_requestconcurrency_np(int queue, int concurrency) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
69int pthread_workqueue_getovercommit_np(pthread_workqueue_t workq, unsigned int *ocommp) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829
A
70/*
71 * If the arg is non zero, it enables kill on current thread.
72 * If the arg of zero, it disables kill on current thread.
73 */
1f2f436a 74int __pthread_workqueue_setkill(int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
224c7076
A
75__END_DECLS
76
77#endif /* _POSIX_PTHREAD_WORKQUEUE_H */
78