📄 attributes.h
字号:
/*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************//** * Copyright (C) 1999 * * This file is part of the C++ Threads library. * * Provides a structure for common attributes, used accross the threads * library. * * Historically, this structure is to provide functional compatibility * with older threads solutions. * * @author Orn E. Hansen <oe.hansen@gamma.telenordia.se> */#ifndef __THREADS_ATTRIBUTES_H#define __THREADS_ATTRIBUTES_Hextern "C" {# include <sched.h>};namespace cpp_threads { /** * Thread attributes. These can be used to change the policy * of a thread, and clones. * * As of 2.0 most of this isn't used, except for the scope * and state attributes. Inheritance and scheduling policy * still remains to be implemented fully. * * @author Orn E. Hansen <oe.hansen@gamma.telenordia.se> */ struct attributes { /** * The scope of a process, shared (used between different * processes), or private (used between different threads). */ enum scope { /** The data is shared between threads only */ process_private_e, /** The data is shared between processes */ process_shared_e }; /** * What will happen, when a child thread is created. Will its * children inherit its state, or is its state explicit to itself. */ enum inheritance { /** Processes will inherit my state. */ attr_inherit_e, /** My state is explicit to me */ attr_explicit_e }; /** * The state of a process, as in if it is a private process that * is running on its own, or weather it is a joinable thread. As * an example, the main thread is detached, but joinable. All its * threads, are joinable. */ enum state { /** The process is joinable */ attr_joinable_e, /** The process has been detached, and is a separate process */ attr_detached_e }; /** * Process scheduling policy, not very useful, except when using * several children threads, and making them have different * scheduling policy under its parent. */ enum policy { /** Other schedule? */ other_e = SCHED_OTHER, /** First created, first served */ fifo_e = SCHED_FIFO, /** Round robin scheduling, the most common */ rrobin_e = SCHED_RR }; scope a_scope; inheritance a_inherit; state a_state; policy a_policy; sched_param a_param; /** * The constructor simply makes defaults of the above attributes. */ attributes(); }; typedef attributes::scope scope_t; typedef attributes::inheritance inheritance_t; typedef attributes::state state_t; typedef attributes::policy policy_t;};#endif /* THREADS ATTRIBUTES */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -