Found 182024 results in 33747 files, showing top 50 files (show more).
github.com/chromium/chromium:native_client_sdk/src/libraries/third_party/pthreads-win32/implement.h: [ master, ]
185:   DWORD thread;			/* Win32 thread ID */
502:   ptw32_thread_t * thread;
158:   HANDLE threadH;		/* Win32 thread handle - POSIX thread is invalid if threadH == 0 */
162:   ptw32_mcs_lock_t threadLock;	/* Used for serialised access to public thread state */
246:   pthread_t ownerThread;
346:   void *threads;
350: typedef struct ThreadParms ThreadParms;
352: struct ThreadParms
401: typedef struct ThreadKeyAssoc ThreadKeyAssoc;
403: struct ThreadKeyAssoc
505:   ThreadKeyAssoc *nextThread;
507:   ThreadKeyAssoc *prevThread;
152: typedef struct ptw32_thread_t_       ptw32_thread_t;
155: struct ptw32_thread_t_
575: #define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *)(size_t) 1)
198: struct pthread_attr_t_
234: struct pthread_mutex_t_
273: struct pthread_mutexattr_t_
302: struct pthread_spinlock_t_
326: struct pthread_barrier_t_
336: struct pthread_barrierattr_t_
341: struct pthread_key_t_
360: struct pthread_cond_t_
378: struct pthread_condattr_t_
385: struct pthread_rwlock_t_
396: struct pthread_rwlockattr_t_
133:   PThreadStateInitial = 0,	/* Thread not running                   */
134:   PThreadStateRunning,		/* Thread alive & kicking               */
135:   PThreadStateSuspended,	/* Thread alive but suspended           */
136:   PThreadStateCancelPending,	/* Thread alive but                     */
138:   PThreadStateCanceling,	/* Thread alive but is                  */
141:   PThreadStateExiting,		/* Thread alive but exiting             */
143:   PThreadStateLast,             /* All handlers have been run and now   */
145:   PThreadStateReuse             /* In reuse pool.                       */
147: PThreadState;
944: #define _beginthreadex(security, \
957: #define _endthreadex ExitThread
129:    * This enumeration represents the state of the thread;
130:    * The thread is still "alive" if the numeric value of the
157:   unsigned __int64 seqNumber;	/* Process-unique thread sequence number */
159:   pthread_t ptHandle;		/* This thread's permanent pthread_t handle */
160:   ptw32_thread_t * prevReuse;	/* Links threads on reuse stack */
242:   int recursive_count;		/* Number of unlocks a thread needs to perform
263:  * Node used to manage per-thread lists of currently-held robust mutexes.
407:    *      This structure creates an association between a thread and a key.
409:    *      destroy routine for thread specific data registered by a user upon
410:    *      exiting a thread.
416:    *         T - Thread that has called pthread_setspecific(Kn)
417:    *            (head of chain is thread->keys)
436:    *      general lock (guarding the row) and the thread's general
440:    *      until both the key is deleted and the thread has called the
442:    *      to be freed as soon as either thread or key is concluded.
445:    *      key and thread locks are acquired consistently in the order
446:    *      "key lock then thread lock". An exception to this exists
447:    *      when a thread calls the destructors, however, this is done
450:    *      An association is created when a thread first calls
455:    *      thread calls the key destructor function on thread exit, or
459:    *      thread
460:    *              reference to the thread that owns the
462:    *              thread struct itself. Since the association is
463:    *              destroyed before the thread exits, this can never
464:    *              point to a different logical thread to the one that
465:    *              created the assoc, i.e. after thread struct reuse.
492:    *      1)      As soon as either the key or the thread is no longer
574: /* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
578: extern ptw32_thread_t * ptw32_threadReuseTop;
579: extern ptw32_thread_t * ptw32_threadReuseBottom;
593: extern ptw32_mcs_lock_t ptw32_thread_reuse_lock;
626:   void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
644:   void ptw32_threadReusePush (pthread_t thread);
648:   int ptw32_setthreadpriority (pthread_t thread, int policy, int priority);
659:   void ptw32_callUserDestroyRoutines (pthread_t thread);
661:   int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key);
6:  * Keeps all the internals out of pthread.h
10:  *      Pthreads-win32 - POSIX Threads Library for Win32
224:   pthread_mutex_t lock;
248: 				   threads. */
267:   pthread_mutex_t mx;
308:     pthread_mutex_t mutex;	/* mutex if single cpu.            */
354:   pthread_t tid;
362:   long nWaitersBlocked;		/* Number of threads blocked            */
363:   long nWaitersGone;		/* Number of threads timed out          */
364:   long nWaitersToUnblock;	/* Number of threads to unblock         */
365:   sem_t semBlockQueue;		/* Queue up threads waiting for the     */
370:   pthread_mutex_t mtxUnblockLock;	/* Mutex that guards access to          */
373:   pthread_cond_t next;		/* Doubly linked list                   */
374:   pthread_cond_t prev;
387:   pthread_mutex_t mtxExclusiveAccess;
388:   pthread_mutex_t mtxSharedAccessCompleted;
389:   pthread_cond_t cndSharedAccessCompleted;
415:    *            (head of chain is key->threads)
451:    *      pthread_setspecific() on a key that has a specified
471:    *              The pthread_t->keys attribute is the head of a
474:    *              between a pthread_t and all pthread_key_t on which
475:    *              it called pthread_setspecific.
480:    *      nextThread
481:    *              The pthread_key_t->threads attribute is the head of
484:    *              relationship between a pthread_key_t and all the 
485:    *              PThreads that have called pthread_setspecific for
486:    *              this pthread_key_t.
488:    *      prevThread
497:    *              pthread_setspecific if the user provided a
503:   pthread_key_t key;
504:   ThreadKeyAssoc *nextKey;
506:   ThreadKeyAssoc *prevKey;
571: /* Declared in pthread_cancel.c */
580: extern pthread_key_t ptw32_selfThreadKey;
581: extern pthread_key_t ptw32_cleanupKey;
582: extern pthread_cond_t ptw32_cond_list_head;
583: extern pthread_cond_t ptw32_cond_list_tail;
587: extern unsigned __int64 ptw32_threadSeqNumber;
601: extern int pthread_count;
617:   int ptw32_is_attr (const pthread_attr_t * attr);
619:   int ptw32_cond_check_need_init (pthread_cond_t * cond);
620:   int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
621:   int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
622:   int ptw32_spinlock_check_need_init (pthread_spinlock_t * lock);
624:   int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
625:   void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
630: 			       HANDLE threadH, DWORD callback_arg);
636:   void ptw32_threadDestroy (pthread_t tid);
640:   pthread_t ptw32_new (void);
642:   pthread_t ptw32_threadReusePop (void);
657:     ptw32_threadStart (void *vthreadParms);
663:   void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
714:   _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
716:   _CRTIMP void __cdecl _endthread (void);
937: #if defined(NEED_CREATETHREAD)
940:  * Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE
950:         CreateThread(security, \
952:                      (LPTHREAD_START_ROUTINE) start_proc, \
959: #endif				/* NEED_CREATETHREAD */
12:  *      Copyright(C) 1999,2005 Pthreads-win32 contributors
20:  *      http://sources.redhat.com/pthreads-win32/contributors.html
131:    * state is greater or equal "PThreadStateRunning".
161:   volatile PThreadState state;
483:    *              nextThreads link. This chain provides the 1 to many
717:   _CRTIMP unsigned long __cdecl _beginthreadex (void *, unsigned,
720:   _CRTIMP void __cdecl _endthreadex (unsigned);
chromium.googlesource.com/chromium/src:native_client_sdk/src/libraries/third_party/pthreads-win32/implement.h: [ master, ] Duplicate result
chromium.googlesource.com/ios-chromium-mirror:native_client_sdk/src/libraries/third_party/pthreads-win32/implement.h: [ master, ] Duplicate result
chromium.googlesource.com/arc/arc:third_party/chromium-ppapi/native_client_sdk/src/libraries/third_party/pthreads-win32/implement.h: [ master, ] Duplicate result
github.com/google/grumpy:third_party/stdlib/threading.py: [ master, ]
631: class Thread(_Verbose):
35: _start_new_thread = thread.start_new_thread
1148: current_thread = currentThread
38: ThreadError = thread.error
1071: class _MainThread(Thread):
1096: def _pickSomeNonDaemonThread():
1111: class _DummyThread(Thread):
1135: def currentThread():
1365:     class ProducerThread(Thread):
1381:     class ConsumerThread(Thread):
1: """Thread module emulating a subset of Java's threading model."""
6:     import thread
31:            'current_thread', 'enumerate', 'Event',
32:            'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
36: _allocate_lock = thread.allocate_lock
37: _get_ident = thread.get_ident
39: del thread
67:                 # Issue #4188: calling current_thread() can incur an infinite
73:                     name = "<OS thread %d>" % ident
93:     The func will be passed to sys.setprofile() for each thread, before its
103:     The func will be passed to sys.settrace() for each thread, before its run()
117:     A reentrant lock must be released by the thread that acquired it. Once a
118:     thread has acquired a reentrant lock, the same thread may acquire it again
119:     without blocking; the thread must release it once for each time it has
126:     """A reentrant lock must be released by the thread that acquired it. Once a
127:        thread has acquired a reentrant lock, the same thread may acquire it
128:        again without blocking; the thread must release it once for each time it
150:         When invoked without arguments: if this thread already owns the lock,
152:         if another thread owns the lock, block until the lock is unlocked. Once
153:         the lock is unlocked (not owned by any thread), then grab ownership, set
154:         the recursion level to one, and return. If more than one thread is
191:         by any thread), and if any other threads are blocked waiting for the
194:         locked and owned by the calling thread.
196:         Only call this method when the calling thread owns the lock. A
246:     notified by another thread.
257:        notified by another thread.
301:         # Return True if lock is owned by current_thread.
312:         If the calling thread has not acquired the lock when this method is
317:         variable in another thread, or until the optional timeout occurs. Once
376:         If the calling thread has not acquired the lock when this method is
403:         If the calling thread has not acquired the lock when this method
445:         on entry, block, waiting until some other thread has called release() to
482:         When the counter is zero on entry and another thread is waiting for it
483:         to become larger than zero again, wake up that thread.
528:         When the counter is zero on entry and another thread is waiting for it
529:         to become larger than zero again, wake up that thread.
567:         # private!  called by Thread._reset_internal_locks by _after_fork()
601:         block until another thread calls set() to set the flag to true, or until
617: # Helper to generate new thread names
619: _counter() # Consume 0 so first non-main thread has id 1.
620: def _newname(template="Thread-%d"):
623: # Active thread administration
625: _active = {}    # maps thread id to Thread object
632:     """A class that represents a thread of control.
649:         *name* is the thread name. By default, a unique name is constructed of
650:         the form "Thread-N" where N is a small decimal number.
658:         the base class constructor (Thread.__init__()) before doing anything
659:         else to the thread.
694:         return current_thread().daemon
697:         assert self.__initialized, "Thread.__init__() was not called"
710:         """Start the thread's activity.
712:         It must be called at most once per thread object. It arranges for the
713:         object's run() method to be invoked in a separate thread of control.
716:         same thread object.
720:             raise RuntimeError("thread.__init__() not called")
724:             self._note("%s.start(): starting thread", self)
728:             _start_new_thread(self.__bootstrap, ())
736:         """Method representing the thread's activity.
748:             # Avoid a refcycle if the thread is running a function with
749:             # an argument that has a member that points to the thread.
755:         # happen when a daemon thread wakes up at an unfortunate
783:                 self._note("%s.__bootstrap(): thread started", self)
805:                     print>>_sys.stderr, ("Exception in thread %s:\n%s" %
814:                             "Exception in thread " + self.name +
860:         "Remove current thread from the dict of currently running threads."
862:         # Notes about running with dummy_thread:
864:         # Must take care to not raise an exception if dummy_thread is being
866:         # dummy_threading).  dummy_thread.get_ident() always returns -1 since
867:         # there is only one thread if dummy_thread is being used.  Thus
868:         # len(_active) is always <= 1 here, and any Thread instance created
869:         # overwrites the (if any) thread currently registered in _active.
872:         # gets overwritten the instant an instance of Thread is created; both
873:         # threads return -1 from dummy_thread.get_ident() and thus have the
876:         # it gets a KeyError if another Thread instance was created.
888:                 # could try to acquire the lock again in the same thread, (in
889:                 # current_thread()), and would block.
895:         """Wait until the thread terminates.
897:         This blocks the calling thread until the thread whose join() method is
905:         thread is still alive, the join() call timed out.
908:         block until the thread terminates.
910:         A thread can be join()ed many times.
913:         thread as that would cause a deadlock. It is also an error to join() a
914:         thread before it has been started and attempts to do so raises the same
919:             raise RuntimeError("Thread.__init__() not called")
921:             raise RuntimeError("cannot join thread before it is started")
922:         if self is current_thread():
923:             raise RuntimeError("cannot join current thread")
927:                 self._note("%s.join(): waiting until thread stops", self)
934:                     self._note("%s.join(): thread stopped", self)
946:                         self._note("%s.join(): thread stopped", self)
957:         assert self.__initialized, "Thread.__init__() not called"
961:         assert self.__initialized, "Thread.__init__() not called"
968:         """Thread identifier of this thread or None if it has not been started.
970:         This is a nonzero integer. See the thread.get_ident() function. Thread
971:         identifiers may be recycled when a thread exits and another thread is
972:         created. The identifier is available even after the thread has exited.
975:         assert self.__initialized, "Thread.__init__() not called"
979:         """Return whether the thread is alive.
986:         assert self.__initialized, "Thread.__init__() not called"
992:         """A boolean value indicating whether this thread is a daemon thread (True) or not (False).
995:         raised. Its initial value is inherited from the creating thread; the
996:         main thread is not a daemon thread and therefore all threads created in
997:         the main thread default to daemon = False.
1003:         assert self.__initialized, "Thread.__init__() not called"
1008:             raise RuntimeError("Thread.__init__() not called")
1010:             raise RuntimeError("cannot set daemon status of active thread");
1041: class _Timer(Thread):
1051:         Thread.__init__(self)
1068: # Special thread class to represent the main thread
1074:         Thread.__init__(self, name="MainThread")
1103: # Dummy thread class to represent threads not started here.
1105: # If they invoke anything in threading.py that calls current_thread(), they
1107: # Their purpose is to return *something* from current_thread().
1114:         Thread.__init__(self, name=_newname("Dummy-%d"))
1116:         # Thread.__block consumes an OS-level locking primitive, which
1130:         assert False, "cannot join a dummy thread"
1136:     """Return the current Thread object, corresponding to the caller's thread of control.
1138:     If the caller's thread of control was not created through the threading
1139:     module, a dummy thread object with limited functionality is returned.
1145:         ##print "current_thread(): no current thread for", _get_ident()
1151:     """Return the number of Thread objects currently alive.
1167:     """Return a list of all Thread objects currently alive.
1169:     The list includes daemonic threads, dummy thread objects created by
1170:     current_thread(), and the main thread. It excludes terminated threads and
1177: from thread import stack_size
1179: # Create the main thread object,
1185: # get thread-local implementation, either from the thread
1188: # NOTE: Thread local classes follow: the Grumpy version of this file copies
1196:         key = '_local__key', 'thread.local.' + str(id(self))
1204:         # We need to create the thread dict in anticipation of
1208:         current_thread().__dict__[key] = dict
1214:     d = current_thread().__dict__.get(key)
1217:         current_thread().__dict__[key] = d
1279:         for thread in threads:
1281:                 __dict__ = thread.__dict__
1283:                 # Thread is dying, rest in peace.
1290:                     pass # didn't have anything in this thread
1300:     # by another (non-forked) thread.  http://bugs.python.org/issue874900
1304:     # fork() only copied the current thread; clear references to others.
1306:     current = current_thread()
1308:         for thread in _enumerate():
1311:             if hasattr(thread, '_reset_internal_locks'):
1312:                 thread._reset_internal_locks()
1313:             if thread is current:
1314:                 # There is only one active thread. We reset the ident to
1317:                 thread.__ident = ident
1318:                 new_active[ident] = thread
1321:                 thread.__stop()
1368:             Thread.__init__(self, name="Producer")
1384:             Thread.__init__(self, name="Consumer")
19: #  This threading model was originally inspired by Java, and inherited
29: # Rename some stuff so "from threading import *" is safe
30: __all__ = ['activeCount', 'active_count', 'Condition', 'currentThread',
45:                         module='threading', message='sys.exc_clear')
68:                 # recursion if it has to create a DummyThread on the fly.
91:     """Set a profile function for all threads started from the threading module.
101:     """Set a trace function for all threads started from the threading module.
245:     A condition variable allows one or more threads to wait until they are
256:     """Condition variables allow one or more threads to wait until they are
374:         """Wake up one or more threads waiting on this condition, if any.
379:         This method wakes up at most n of the threads waiting for the condition
380:         variable; it is a no-op if no threads are waiting.
401:         """Wake up all threads waiting on this condition.
449:         which blocked threads are awakened should not be relied on. There is no
579:         All threads waiting for the flag to become true are awakened. Threads
590:         Subsequently, threads calling wait() will block until set() is called to
629: # Main class for threads
643:         *group* should be None; reserved for future extension when a ThreadGroup
683:         if hasattr(self, '__block'):  # DummyThread deletes self.__block
693:         # Overridden in _MainThread and _DummyThread
722:             raise RuntimeError("threads can only be started once")
763:         # reported.  Also, we only suppress them for daemonic threads;
835:                 # test_threading.test_no_refcycle_through_target when
871:         # An instance of _MainThread is always created by 'threading'.  This
874:         # same key in the dict.  So when the _MainThread instance created by
875:         # 'threading' tries to clean itself up when atexit calls this method
879:         # _active if dummy_threading is being used is a red herring.  But
880:         # since it isn't if dummy_threading is *not* being used then don't
891:             if 'dummy_threading' not in _sys.modules:
953:         It has no semantics. Multiple threads may be given the same name. The
983:         returns a list of all alive threads.
999:         The entire Python program exits when no alive non-daemon threads are
1085:         t = _pickSomeNonDaemonThread()
1088:                 self._note("%s: waiting for other threads", self)
1091:             t = _pickSomeNonDaemonThread()
1108: # They are marked as daemon threads so we won't wait for them
1117:         # can never be used by a _DummyThread.  Since a _DummyThread
1146:         return _DummyThread()
1171:     threads that have not yet been started.
1181: # (Py_Main) as threading._shutdown.
1183: _shutdown = _MainThread()._exitfunc
1189: # these from _threading_local.py to avoid circular dependency issues.
1272:             threads = _enumerate()
1274:             # If enumerating the current threads fails, as it seems to do
1292: # END _threading_local.py copy
1296:     # is called from PyOS_AfterFork.  Here we cleanup threading module state
1401:         t = ProducerThread(Q, NI)
1404:     C = ConsumerThread(Q, NI*NP)
850:         # DummyThreads delete self.__block, but they have no waiters to
1295:     # This function is called by Python/ceval.c:PyEval_ReInitThreads which
github.com/html5rocks/slides.html5rocks.com:src/canvasphoto/utilities.js: [ master, ]
333: ...(751 bytes skipped)....subscribe(onTween);this._onComplete.subscribe(onComplete);}};YAHOO.util.AnimMgr=new function(){var thread=null;var queue=[];var tweenCount=0;this.fps=1000;this.delay=1;this.registerElement=function(tween){...(197 bytes skipped)...
83: ...(5 bytes skipped)...n id;};return Y.Dom.batch(el,f,Y.Dom,true)||f.apply(Y.Dom,arguments);},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false;}
86: return false;};return Y.Dom.batch(needle,f,Y.Dom,true);},inDocument:function(el){var f=function(el){if(isSafari){while(el=el.parentNode){if(...(44 bytes skipped)...
335: return true;};this.start=function(){if(thread===null){thread=setInterval(this.run,this.delay);}};this.stop=function(tween){if(!tween){clearInterval(thread);for(var i=0,len=queue.length;i<len;++i){if(queue[0].isAnimated()){this.unRegister(queue[0],0);}}
336: queue=[];thread=null;tweenCount=0;}
android.googlesource.com/trusty/lk/common:include/kernel/thread.h: [ master, ]
87: typedef struct thread {
45: #define THREAD_STATS 1
46: #define THREAD_STACK_HIGHWATER 1
47: #define THREAD_STACK_BOUNDS_CHECK 1
49: #define THREAD_STACK_PADDING_SIZE 256
53: enum thread_state {
54:     THREAD_SUSPENDED = 0,
55:     THREAD_READY,
56:     THREAD_RUNNING,
57:     THREAD_BLOCKED,
58:     THREAD_SLEEPING,
59:     THREAD_DEATH,
62: typedef int (*thread_start_routine)(void *arg);
65: enum thread_tls_list {
78: #define THREAD_FLAG_DETACHED                  (1U<<0)
79: #define THREAD_FLAG_FREE_STACK                (1U<<1)
80: #define THREAD_FLAG_FREE_STRUCT               (1U<<2)
81: #define THREAD_FLAG_REAL_TIME                 (1U<<3)
82: #define THREAD_FLAG_IDLE                      (1U<<4)
83: #define THREAD_FLAG_DEBUG_STACK_BOUNDS_CHECK  (1U<<5)
85: #define THREAD_MAGIC (0x74687264) // 'thrd'
89:     struct list_node thread_list_node;
128: } thread_t;
131: #define thread_curr_cpu(t) ((t)->curr_cpu)
132: #define thread_pinned_cpu(t) ((t)->pinned_cpu)
133: #define thread_set_curr_cpu(t,c) ((t)->curr_cpu = (c))
134: #define thread_set_pinned_cpu(t, c) ((t)->pinned_cpu = (c))
136: #define thread_curr_cpu(t) (0)
137: #define thread_pinned_cpu(t) (-1)
138: #define thread_set_curr_cpu(t,c) do {} while(0)
139: #define thread_set_pinned_cpu(t, c) do {} while(0)
197: #define THREAD_LOCK(state) spin_lock_saved_state_t state; spin_lock_irqsave(&thread_lock, state)
198: #define THREAD_UNLOCK(state) spin_unlock_irqrestore(&thread_lock, state)
200: static inline bool thread_lock_held(void)
226: struct thread_stats {
244: #define THREAD_STATS_INC(name) do { thread_stats[arch_curr_cpu_num()].name++; } while(0)
248: #define THREAD_STATS_INC(name) do { } while (0)
24: #define __KERNEL_THREAD_H
23: #ifndef __KERNEL_THREAD_H
31: #include <arch/thread.h>
48: #ifndef THREAD_STACK_PADDING_SIZE
64: /* thread local storage */
94:     enum thread_state state;
110:     struct arch_thread arch;
117:     thread_start_routine entry;
124:     /* thread local storage */
142: /* thread priority */
160: void thread_init_early(void);
161: void thread_init(void);
162: void thread_become_idle(void) __NO_RETURN;
163: void thread_secondary_cpu_init_early(void);
164: void thread_secondary_cpu_entry(void) __NO_RETURN;
165: void thread_set_name(const char *name);
166: void thread_set_priority(int priority);
167: thread_t *thread_create(const char *name, thread_start_routine entry, void *arg, int priority, size_t stack_size);
168: thread_t *thread_create_etc(thread_t *t, const char *name, thread_start_routine entry, void *arg, int priority, void *stack, size_t stack_size);
169: status_t thread_resume(thread_t *);
170: void thread_exit(int retcode) __NO_RETURN;
171: void thread_sleep(lk_time_t delay);
172: status_t thread_detach(thread_t *t);
173: status_t thread_join(thread_t *t, int *retcode, lk_time_t timeout);
174: status_t thread_detach_and_resume(thread_t *t);
175: status_t thread_set_real_time(thread_t *t);
177: void dump_thread(thread_t *t);
178: void arch_dump_thread(thread_t *t);
182: void thread_yield(void); /* give up the cpu voluntarily */
183: void thread_preempt(void); /* get preempted (inserted into head of run queue) */
184: void thread_block(void); /* block on something and reschedule */
185: void thread_unblock(thread_t *t, bool resched); /* go back in the run queue */
188: enum handler_return thread_timer_tick(void);
190: /* the current thread */
191: thread_t *get_current_thread(void);
192: void set_current_thread(thread_t *);
195: extern spin_lock_t thread_lock;
202:     return spin_lock_held(&thread_lock);
205: /* thread local storage */
208:     return get_current_thread()->tls[entry];
213:     uintptr_t oldval = get_current_thread()->tls[entry];
214:     get_current_thread()->tls[entry] = val;
224: /* thread level statistics */
225: #if THREAD_STATS
242: extern struct thread_stats thread_stats[SMP_MAX_CPUS];
179: void dump_all_threads(void);
github.com/apache/activemq-cpp:activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp: [ master, ]
153:             Pointer<Thread> thread;
957:         bool prestartCoreThread() {
1353: ThreadPoolExecutor::ThreadPoolExecutor(int corePoolSize, int maxPoolSize,
1382: ThreadPoolExecutor::ThreadPoolExecutor(int corePoolSize, int maxPoolSize,
1414: ThreadPoolExecutor::ThreadPoolExecutor(int corePoolSize, int maxPoolSize,
1446: ThreadPoolExecutor::ThreadPoolExecutor(int corePoolSize, int maxPoolSize,
1690: bool ThreadPoolExecutor::prestartCoreThread() {
1478: ThreadPoolExecutor::~ThreadPoolExecutor() {
315:         bool coreThreadsCanTimeout;
961:         int prestartAllCoreThreads() {
969:         void allowCoreThreadTimeOut(bool value) {
1614: void ThreadPoolExecutor::setThreadFactory(ThreadFactory* factory) {
1627: ThreadFactory* ThreadPoolExecutor::getThreadFactory() const {
1670: void ThreadPoolExecutor::allowCoreThreadTimeout(bool value) {
1685: bool ThreadPoolExecutor::allowsCoreThreadTimeout() const {
1695: int ThreadPoolExecutor::prestartAllCoreThreads() {
61:      * task deletion logic can remain unchanged and thread safe.
102:      * for example when a ThreadFactory fails to create a thread when
114:      *             the thread transitioning to state TIDYING
168:                 AbstractQueuedSynchronizer(), Runnable(), thread(), firstTask(task), kernel(kernel), completedTasks(0) {
175:                 this->thread.reset(kernel->factory->newThread(this));
210:                     setExclusiveOwnerThread(Thread::currentThread());
226:          * to the Timer's thread.
307:          * up on a separate thread because the Worker generally adds itself to the deadWorkers
422:                     worker->thread->join();
593:                     iter->next()->thread->interrupt();
611:          *      currently waiting.  Interrupting any arbitrary thread ensures that
624:                     Pointer<Thread> thread = worker->thread;
625:                     if (!thread->isInterrupted() && worker->tryLock()) {
627:                             thread->interrupt();
656:          * Ensures that unless the pool is stopping, the current thread does not have
661:             if (this->runStateLessThan(ctl.get(), STOP) && Thread::interrupted() &&
664:                 Thread::currentThread()->interrupt();
690:          * usually leads processWorkerExit to replace this thread.
695:          * stopping, this thread does not have its interrupt set.
698:          * might throw an exception, in which case we cause thread to die
708:          * thread's UncaughtExceptionHandler).  Any thrown exception also
709:          * conservatively causes thread to die.
712:          * also throw an exception, which will also cause thread to
717:          * and the thread's UncaughtExceptionHandler have as accurate
732:                         this->parent->beforeExecute(w->thread.get(), task);
796:              * start a new thread with the given command as its first
802:              * to double-check whether we should have added a thread
806:              * stopped, or start a new thread if there are none.
809:              * thread.  If it fails, we know we are shut down or saturated
1106:          * if the thread factory fails to create a thread when asked, which requires
1111:          *      The task the new thread should run first (or null if none).
1153:             Pointer<Thread> t = w->thread;
1187:             // It is possible (but unlikely) for a thread to have been added to
1189:             // could result in a rare missed interrupt, because Thread::interrupt
1190:             // is not guaranteed to have any effect on a non-yet-started Thread
1191:             // (see Thread#interrupt).
1203:          * thread from worker set, and possibly terminates the pool or replaces the
1329:          * abrupt termination of a thread (see processWorkerExit). Other
1710: void ThreadPoolExecutor::beforeExecute(Thread* thread DECAF_UNUSED, Runnable* task DECAF_UNUSED) {
18: #include "ThreadPoolExecutor.h"
89:      *   workerCount, indicating the effective number of threads
93:      * (2^29)-1 (about 500 million) threads rather than (2^31)-1 (2
101:      * transiently different from the actual number of live threads,
103:      * asked, and when exiting threads are still performing
133:      * Threads waiting in awaitTermination() will return when the
172:                         "ThreadPoolExecutor Worker requires non-NULL pointer to parent ExecutorKernel");
217:                 this->setExclusiveOwnerThread(NULL);
291:         ThreadPoolExecutor* parent;
294:          * List containing all worker threads in pool. Accessed only when holding mainLock.
318:          * The queue used for holding tasks and handing off to worker threads.
333:          * Otherwise exiting threads would concurrently interrupt those that have not
349:         Pointer<ThreadFactory> factory;
354:         ExecutorKernel(ThreadPoolExecutor* parent,
357:                        ThreadFactory* threadFactory, RejectedExecutionHandler* handler) :
381:            if(workQueue == NULL || threadFactory == NULL || handler == NULL) {
389:            this->factory.reset(threadFactory);
417:                 // Ensure dead Worker Threads are destroyed, the Timer might not have
586:          * Force an interrupt of all threads even if they are currently active.
603:          * Interrupts threads that might be waiting for tasks (as indicated by not
610:          *      interrupted to propagate shutdown signals in case all threads are
795:              * 1. If fewer than corePoolSize threads are running, try to
799:              * threads when it shouldn't, by returning false.
932:                 // We don't really know how many new threads are "needed".
972:                     "Core threads must have nonzero keep alive times");
990:                     "Core threads must have nonzero keep alive times");
1113:          *      to bypass queuing when there are fewer than corePoolSize threads
1115:          *      (in which case we must bypass queue). Initially idle threads are
1116:          *      usually created via prestartCoreThread or to replace other dying workers.
1157:                 // Recheck while holding lock. Back out on ThreadFactory failure or if
1201:          * worker threads. Unless completedAbruptly is set, assumes that workerCount
1365:         Pointer<RejectedExecutionHandler> handler(new ThreadPoolExecutor::AbortPolicy());
1366:         Pointer<ThreadFactory> threadFactory(Executors::getDefaultThreadFactory());
1370:             threadFactory.get(), handler.get());
1373:         threadFactory.release();
1399:         Pointer<ThreadFactory> threadFactory(Executors::getDefaultThreadFactory());
1403:             threadFactory.get(), handler);
1405:         threadFactory.release();
1417:                                        ThreadFactory* threadFactory) :
1427:         if(threadFactory == NULL) {
1428:             throw NullPointerException(__FILE__, __LINE__, "The ThreadFactory pointer cannot be NULL.");
1431:         Pointer<RejectedExecutionHandler> handler(new ThreadPoolExecutor::AbortPolicy());
1435:             threadFactory, handler.get());
1449:                                        ThreadFactory* threadFactory, RejectedExecutionHandler* handler) :
1463:         if(threadFactory == NULL) {
1464:             throw NullPointerException(__FILE__, __LINE__, "The ThreadFactory pointer cannot be NULL.");
1469:             threadFactory, handler);
1488: void ThreadPoolExecutor::execute(Runnable* task) {
1495:                 "ThreadPoolExecutor::execute - Supplied Runnable pointer was NULL.");
1507: void ThreadPoolExecutor::execute(Runnable* task, bool takeOwnership) {
1514:                 "ThreadPoolExecutor::execute - Supplied Runnable pointer was NULL.");
1526: void ThreadPoolExecutor::shutdown() {
1536: ArrayList<Runnable*> ThreadPoolExecutor::shutdownNow() {
1549: bool ThreadPoolExecutor::awaitTermination(long long timeout, const TimeUnit& unit) {
1559: int ThreadPoolExecutor::getPoolSize() const {
1564: int ThreadPoolExecutor::getCorePoolSize() const {
1569: void ThreadPoolExecutor::setCorePoolSize(int poolSize) {
1579: int ThreadPoolExecutor::getMaximumPoolSize() const {
1584: void ThreadPoolExecutor::setMaximumPoolSize(int maxSize) {
1594: long long ThreadPoolExecutor::getTaskCount() const {
1599: int ThreadPoolExecutor::getActiveCount() const {
1604: long long ThreadPoolExecutor::getCompletedTaskCount() const {
1609: int ThreadPoolExecutor::getLargestPoolSize() const {
1617:         throw NullPointerException(__FILE__, __LINE__, "Cannot assign a NULL ThreadFactory.");
1621:         Pointer<ThreadFactory> temp(factory);
1632: RejectedExecutionHandler* ThreadPoolExecutor::getRejectedExecutionHandler() const {
1637: void ThreadPoolExecutor::setRejectedExecutionHandler(RejectedExecutionHandler* handler) {
1650: BlockingQueue<Runnable*>* ThreadPoolExecutor::getQueue() {
1655: bool ThreadPoolExecutor::isShutdown() const {
1660: bool ThreadPoolExecutor::isTerminated() const {
1665: bool ThreadPoolExecutor::isTerminating() const {
1675: long long ThreadPoolExecutor::getKeepAliveTime(const TimeUnit& unit) const {
1680: void ThreadPoolExecutor::setKeepAliveTime(long long timeout, const TimeUnit& unit) {
1691:     return this->kernel->prestartCoreThread();
1700: bool ThreadPoolExecutor::remove(decaf::lang::Runnable* task) {
1705: void ThreadPoolExecutor::purge() {
1714: void ThreadPoolExecutor::afterExecute(Runnable* task DECAF_UNUSED, decaf::lang::Throwable* error DECAF_UNUSED) ...(1 bytes skipped)...
1718: void ThreadPoolExecutor::terminated() {
1722: void ThreadPoolExecutor::onShutdown() {
366:            coreThreadsCanTimeout(false),
540:          * allow access from ScheduledThreadPoolExecutor.
669:          * State check needed by ScheduledThreadPoolExecutor to enable running
975:             if (value != this->coreThreadsCanTimeout) {
976:                 this->coreThreadsCanTimeout = value;
988:             if (time == 0 && this->coreThreadsCanTimeout) {
1232:                     int min = this->coreThreadsCanTimeout ? 0 : corePoolSize;
1254:          *     {@code allowCoreThreadTimeOut || workerCount > corePoolSize})
1277:                     timed = this->coreThreadsCanTimeout || wc > this->corePoolSize;
1671:     this->kernel->allowCoreThreadTimeOut(value);
1686:     return this->kernel->coreThreadsCanTimeout;
1696:     return this->kernel->prestartAllCoreThreads();
github.com/rosjava/rosjava_core:apache_xmlrpc_common/src/main/java/org/apache/xmlrpc/util/ThreadPool.java: [ kinetic, ]
50:         private Thread thread;
28: public class ThreadPool {
111: 	private final ThreadGroup threadGroup;
123: 	public ThreadPool(int pMaxSize, String pName) {
113: 	private final List waitingThreads = new ArrayList();
114: 	private final List runningThreads = new ArrayList();
226: 	public int getMaxThreads() { return maxSize; }
231:     public synchronized int getNumThreads() { return num; }
25: /** Simple thread pool. A task is executed by obtaining a thread from
29: 	/** The thread pool contains instances of {@link ThreadPool.Task}.
33: 		 * @throws Throwable The task failed, and the worker thread won't be used again.
52:             thread = new Thread(pGroup, pGroup.getName() + "-" + pNum){
80:             thread.start();
93:             synchronized (thread) {
94:                 thread.notify();
105:             synchronized (thread) {
106:                 thread.notify();
121: 	 * @param pName Thread group name.
51:         Poolable(ThreadGroup pGroup, int pNum) {
120: 	 * @param pMaxSize Maximum number of concurrent threads.
125: 		threadGroup = new ThreadGroup(pName);
167: 	 * might consider to use the {@link #addTask(ThreadPool.Task)} method instead.
189:             poolable = new Poolable(threadGroup, num++);
223: 	/** Returns the maximum number of concurrent threads.
224: 	 * @return Maximum number of threads.
228: 	/** Returns the number of threads, which have actually been created,
229:      * as opposed to the number of currently running threads.
129:         runningThreads.remove(pPoolable);
130:         waitingThreads.remove(pPoolable);
138: 	        if (runningThreads.remove(pPoolable)) {
139: 	            if (maxSize != 0  &&  runningThreads.size() + waitingThreads.size() >= maxSize) {
142: 	                waitingThreads.add(pPoolable);
179:         if (maxSize != 0  &&  runningThreads.size() >= maxSize) {
186:         if (waitingThreads.size() > 0) {
187:             poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
191:         runningThreads.add(poolable);
213:         while (!waitingThreads.isEmpty()) {
214:             Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
217:         while (!runningThreads.isEmpty()) {
218:             Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1);
github.com/googleapis/elixir-google-api:clients/chat/lib/google_api/chat/v1/model/thread.ex: [ master, ]
18: defmodule GoogleApi.Chat.V1.Model.Thread do
20:   A thread in Hangouts Chat.
38: defimpl Poison.Decoder, for: GoogleApi.Chat.V1.Model.Thread do
40:     GoogleApi.Chat.V1.Model.Thread.decode(value, options)
44: defimpl Poison.Encoder, for: GoogleApi.Chat.V1.Model.Thread do
24:   *   `name` (*type:* `String.t`, *default:* `nil`) - Resource name, in the form "spaces/*/threads/*".
26:       Example: spaces/AAAAMpdlehY/threads/UMxbHmzDlr4
github.com/apache/logging-log4cxx:src/main/cpp/threadcxx.cpp: [ master, ]
92: 		Thread* thread;
153: Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
158: Thread::~Thread()
68: 		Thread* getThread() const
291: bool Thread::isCurrentThread() const
131: ThreadLocal& getThreadLocal()
245: void Thread::currentThreadInterrupt()
19: #include <log4cxx/helpers/thread.h>
21: #include <apr_thread_proc.h>
26: #include <apr_thread_cond.h>
36:  *   Thread::run when they are passed to Thread::launcher.
46: 		 *  before thread is launched.
61: 		LaunchPackage(Thread* t, Runnable r, void* d) : thread(t), runnable(r), data(d)
65: 		 * Gets thread parameter.
66: 		 * @return thread.
70: 			return thread;
83: 		 *  @return thread.
100:  *  Used to maintain Thread.alive.
128:  *   Get a key to the thread local storage used to hold the reference to
129:  *   the corresponding Thread object.
139: void* LOG4CXX_THREAD_FUNC ThreadLaunch::launcher(apr_thread_t* thread, void* data)
145: 		(package->getRunnable())(thread, package->getData());
148: 	apr_thread_exit(thread, 0); // this function never returns !
165: void Thread::run(Runnable start, void* data)
175: 	// now we're ready to create the thread again
177: 	//    if attempting a second run method on the same Thread object
180: 	if (thread != NULL)
193: 	stat = apr_thread_cond_create(&interruptedCondition, p.getAPRPool());
200: 	stat = apr_thread_mutex_create(&interruptedMutex, APR_THREAD_MUTEX_NESTED,
208: 	//   create LaunchPackage on the thread's memory pool
210: 	stat = apr_thread_create(&thread, attrs,
219: 	// if run() has been called in a thread-safe way.
226: void Thread::join()
230: 	if (thread != NULL)
233: 		apr_status_t stat = apr_thread_join(&startStat, thread);
234: 		thread = NULL;
252: 		((Thread*) tls)->interrupt();
258: void Thread::interrupt()
266: 		apr_status_t stat = apr_thread_cond_signal(interruptedCondition);
277: bool Thread::interrupted()
284: 		return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
301: bool Thread::isAlive()
306: void Thread::ending()
312: void Thread::sleep(int duration)
323: 		Thread* pThis = (Thread*) getThreadLocal().get();
332: 			apr_status_t stat = apr_thread_cond_timedwait(pThis->interruptedCondition,
24: #include <log4cxx/helpers/threadlocal.h>
31: #if APR_HAS_THREADS
133: 	static ThreadLocal tls;
142: 	ThreadLocal& tls = getThreadLocal();
143: 	tls.set(package->getThread());
146: 		package->getThread()->ending();
167: #if APR_HAS_THREADS
185: 	apr_threadattr_t* attrs;
186: 	apr_status_t stat = apr_threadattr_create(&attrs, p.getAPRPool());
190: 		throw ThreadException(stat);
197: 		throw ThreadException(stat);
205: 		throw ThreadException(stat);
211: 			ThreadLaunch::launcher, package, p.getAPRPool());
215: 		throw ThreadException(stat);
222: 	throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
228: #if APR_HAS_THREADS
238: 			throw ThreadException(stat);
247: #if APR_HAS_THREADS
261: #if APR_HAS_THREADS
270: 			throw ThreadException(stat);
279: #if APR_HAS_THREADS
293: #if APR_HAS_THREADS
314: #if APR_HAS_THREADS
337: 				throw ThreadException(stat);
248: 	void* tls = getThreadLocal().get();
280: 	void* tls = getThreadLocal().get();
294: 	const void* tls = getThreadLocal().get();
github.com/googlegsa/sharepoint.v3:projects/ApacheHttpClient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java: [ master, ]
1046:         public Thread thread;
93:     private static ReferenceQueueThread REFERENCE_QUEUE_THREAD;
917:         public synchronized void notifyWaitingThread(HostConfiguration configuration) {
928:         public synchronized void notifyWaitingThread(HostConnectionPool hostPool) {
1044:     private static class WaitingThread {
1061:     private static class ReferenceQueueThread extends Thread {
1068:         public ReferenceQueueThread() {
65: public class MultiThreadedHttpConnectionManager implements HttpConnectionManager {
256:     public MultiThreadedHttpConnectionManager() {
706:         private LinkedList waitingThreads = new LinkedList();
1034:         public LinkedList waitingThreads = new LinkedList();
91:      * The thread responsible for handling lost connections.
134:             if (REFERENCE_QUEUE_THREAD != null) {
135:                 REFERENCE_QUEUE_THREAD.shutdown();
136:                 REFERENCE_QUEUE_THREAD = null;
171:             // start the reference queue thread if needed
172:             if (REFERENCE_QUEUE_THREAD == null) {
173:                 REFERENCE_QUEUE_THREAD = new ReferenceQueueThread();
174:                 REFERENCE_QUEUE_THREAD.start();
507:                             waitingThread.thread = Thread.currentThread();
531:                             // interrupted by an external thread.  Regardless we need to 
624:      * If another thread is blocked in getConnection() that could use this
741:                 waiter.thread.interrupt();
912:          * Notifies a waiting thread that a connection for the given configuration is 
922:          * Notifies a waiting thread that a connection for the given configuration is 
923:          * available.  This will wake a thread waiting in this host pool or if there is not
924:          * one a thread in the connection pool will be notified.
930:             // find the thread we are going to notify, we want to ensure that each
931:             // waiting thread is only interrupted once so we will remove it from 
937:                     LOG.debug("Notifying thread waiting on host pool, hostConfig=" 
944:                     LOG.debug("No-one waiting on host pool, notifying next waiting thread.");
954:                 waitingThread.thread.interrupt();
1041:      * A simple struct-like class to combine the waiting thread and the connection 
1045:         /** The thread that is waiting for a connection */
1048:         /** The connection pool the thread is waiting for */
1051:         /** Flag to indicate if the thread was interrupted by the ConnectionPool. Set
1053:          * before the thread is interrupted. */
1058:      * A thread for listening for HttpConnections reclaimed by the garbage
1066:          * Create an instance and make this a daemon thread.
105:      * MultiThreadedHttpConnectionManager. All static resources are released, all threads are 
453:             WaitingThread waitingThread = null;
492:                     // threads, so they avoid being sacrificed before necessary
504:                         if (waitingThread == null) {
505:                             waitingThread = new WaitingThread();
506:                             waitingThread.hostConnectionPool = hostPool;
509:                             waitingThread.interruptedByConnectionPool = false;
516:                         hostPool.waitingThreads.addLast(waitingThread);
517:                         connectionPool.waitingThreads.addLast(waitingThread);
520:                         if (!waitingThread.interruptedByConnectionPool) {
529:                         if (!waitingThread.interruptedByConnectionPool) {
533:                             hostPool.waitingThreads.remove(waitingThread);
534:                             connectionPool.waitingThreads.remove(waitingThread);
735:             // interrupt all waiting threads
738:                 WaitingThread waiter = (WaitingThread) iter.next();
777:          * connection counts and notifies waiting threads, if appropriate.
787:             notifyWaitingThread(config);
915:          * @see #notifyWaitingThread(HostConnectionPool)
918:             notifyWaitingThread(getHostPool(configuration));
933:             WaitingThread waitingThread = null;
940:                 waitingThread = (WaitingThread) hostPool.waitingThreads.removeFirst();
941:                 waitingThreads.remove(waitingThread);
946:                 waitingThread = (WaitingThread) waitingThreads.removeFirst();
947:                 waitingThread.hostConnectionPool.waitingThreads.remove(waitingThread);
949:                 LOG.debug("Notifying no-one, there are no waiting threads");
952:             if (waitingThread != null) {
953:                 waitingThread.interruptedByConnectionPool = true;
1004:                 notifyWaitingThread(hostPool);
1052:          * to true inside {@link ConnectionPool#notifyWaitingThread(HostConnectionPool)} 
1115:                     LOG.debug("ReferenceQueueThread interrupted", e);
2: ...(43 bytes skipped)...ommons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v 1.47 2004/12/21 11:27:55 olegk Exp $
70:     private static final Log LOG = LogFactory.getLog(MultiThreadedHttpConnectionManager.class);
107:      * MultiThreadedHttpConnectionManager.
118:                 MultiThreadedHttpConnectionManager[]
119:                     connManagers = (MultiThreadedHttpConnectionManager[])
121:                         new MultiThreadedHttpConnectionManager
522:                             throw new IllegalThreadStateException(
523:                                 "Interrupted while waiting in MultiThreadedHttpConnectionManager");
705:         /** The list of WaitingThreads waiting for a connection */
736:             iter = waitingThreads.iterator();
764:             connection.getParams().setDefaults(MultiThreadedHttpConnectionManager.this.params);
765:             connection.setHttpConnectionManager(MultiThreadedHttpConnectionManager.this);
935:             if (hostPool.waitingThreads.size() > 0) {
942:             } else if (waitingThreads.size() > 0) {
1033:         /** The list of WaitingThreads for this host */
1070:             setName("MultiThreadedHttpConnectionManager cleanup");
github.com/google/starlark-go:starlark/eval.go: [ master, ]
29: type Thread struct {
26: // A Thread contains the state of a Starlark thread,
27: // such as its call stack and thread-local storage.
28: // The Thread is threaded throughout the evaluator.
30: 	// Name is an optional name that describes the thread, for debugging.
39: 	Print func(thread *Thread, msg string)
47: 	Load func(thread *Thread, module string) (StringDict, error)
49: 	// locals holds arbitrary "thread-local" Go values belonging to the client.
57: // SetLocal sets the thread-local value associated with the specified key.
59: func (thread *Thread) SetLocal(key string, value interface{}) {
60: 	if thread.locals == nil {
61: 		thread.locals = make(map[string]interface{})
63: 	thread.locals[key] = value
66: // Local returns the thread-local value associated with the specified key.
67: func (thread *Thread) Local(key string) interface{} {
68: 	return thread.locals[key]
76: func (thread *Thread) CallFrame(depth int) CallFrame {
77: 	return thread.frameAt(depth).asCallFrame()
80: func (thread *Thread) frameAt(depth int) *frame {
81: 	return thread.stack[len(thread.stack)-1-depth]
84: // CallStack returns a new slice containing the thread's stack of call frames.
85: func (thread *Thread) CallStack() CallStack {
86: 	frames := make([]CallFrame, len(thread.stack))
87: 	for i, fr := range thread.stack {
94: func (thread *Thread) CallStackDepth() int { return len(thread.stack) }
189: // a copy of the thread's stack at the moment of the error.
210: func (thread *Thread) evalError(err error) *EvalError {
213: 		CallStack: thread.CallStack(),
269: // Thread is the state associated with the Starlark thread.
283: func ExecFile(thread *Thread, filename string, src interface{}, predeclared StringDict) (StringDict, error) {
290: 	g, err := mod.Init(thread, predeclared)
359: func (prog *Program) Init(thread *Thread, predeclared StringDict) (StringDict, error) {
362: 	_, err := Call(thread, toplevel, nil, nil)
369: // ExecREPLChunk compiles and executes file f in the specified thread
377: func ExecREPLChunk(f *syntax.File, thread *Thread, globals StringDict) error {
408: 	_, err := Call(thread, toplevel, nil, nil)
461: func Eval(thread *Thread, filename string, src interface{}, env StringDict) (Value, error) {
470: 	return Call(thread, f, nil, nil)
485: func EvalExpr(thread *Thread, expr syntax.Expr, env StringDict) (Value, error) {
490: 	return Call(thread, fn, nil, nil)
896: 			needle, ok := x.(String)
900: 			return Bool(strings.Contains(string(y), string(needle))), nil
1062: func Call(thread *Thread, fn Value, args Tuple, kwargs []Tuple) (Value, error) {
1070: 	// Optimization: use slack portion of thread.stack
1072: 	if n := len(thread.stack); n < cap(thread.stack) {
1073: 		fr = thread.stack[n : n+1][0]
1078: 	thread.stack = append(thread.stack, fr) // push
1082: 	thread.beginProfSpan()
1083: 	result, err := c.CallInternal(thread, args, kwargs)
1084: 	thread.endProfSpan()
1094: 			err = thread.evalError(err)
1099: 	thread.stack = thread.stack[:len(thread.stack)-1] // pop
github.com/googlecreativelab/chrome-music-lab:harmonics & strings/js/Thread.js: [ master, ]
5: var Thread = function(xp0Pm, yp0Pm, xp1Pm, yp1Pm, indPm, indHarmonicPm, isTopPm, threadControllerPm) {
1: // class:	Thread
52: 	// how close do we have to be to instantly grab a thread - perpendicular distance (px)
60: 	// total length of this thread (when unstretched)
131: Thread.prototype.init = function() {
140: Thread.prototype.redraw = function() {
185: Thread.prototype.upd = function() {
186: 	// is thread currently grabbed
189: 	// is thread currently oscillating
198: Thread.prototype.updOsc = function() {
248: Thread.prototype.updGrab = function() {
250: 	// is this thread being held by a fish?
291: Thread.prototype.stopNote = function() {
298: Thread.prototype.pluck = function(xp, yp, byUser, fish) {
366: Thread.prototype.grab = function(xp, yp, byUser, car) {
386: Thread.prototype.drop = function() {
416: Thread.prototype.startOsc = function() {
430: Thread.prototype.playNote = function(vol, pan) {
445: Thread.prototype.setStretch = function(r) {
452: // desc:      Check when user first clicks if they clicked right on top of a thread,
455: Thread.prototype.checkInstantGrab = function() {
479: // desc:      Check when user first clicks if they clicked right on top of a thread,
482: Thread.prototype.setPosition = function(x0, y0, x1, y1) {
6: 	this.m = threadControllerPm;
67: 	// my overall index number of all threads
278: 		this.m.dropThread(this);
474: 		this.m.grabThread(this, xu, yu, true, null);
github.com/apache/attic-polygene-sandbox:libraries/thread/src/main/java/org/qi4j/library/thread/PooledThreadServiceMixin.java: [ master, ]
105:         private final Thread thread;
18: package org.qi4j.library.thread;
33:     @Service private ThreadGroupService threadGroupService;
35:     private int threadCount;
43:     public Thread newThread( Runnable runnable )
78:     private void createNewThread()
103:     public static class RunnableThread
108:         public RunnableThread( Thread thread, PooledRunnableWrapper runnable )
28: public class PooledThreadServiceMixin
37:     public PooledThreadServiceMixin()
58:             return rt.thread;
85:         Thread t = new Thread( group, runnable, name );
95:         for( RunnableThread thread : pool )
98:             thread.runnable.run = false;
99:             thread.thread.interrupt();
110:             this.thread = thread;
29:     implements ThreadService, Activatable
31:     @This private Configuration<ThreadServiceConfiguration> config;
34:     private LinkedList<RunnableThread> pool;
39:         pool = new LinkedList<RunnableThread>();
40:         threadCount = 0;
50:                 if( threadCount >= max )
54:                 createNewThread();
56:             RunnableThread rt = pool.removeFirst();
62:     public ThreadServiceConfiguration configuration()
70:         pool = new LinkedList<RunnableThread>();
74:             createNewThread();
80:         ThreadServiceConfiguration configuration = config.configuration();
81:         String tgName = configuration.threadGroupName().get();
82:         ThreadGroup group = threadGroupService.getThreadGroup( tgName );
83:         String name = configuration.threadBaseName().get() + "-" + sequence.newSequenceValue();
86:         RunnableThread runnableThread = new RunnableThread( t, runnable );
87:         runnable.poolInstance = runnableThread;
88:         threadCount++;
89:         pool.add( runnableThread );
97:             threadCount = 0;
120:         private RunnableThread poolInstance;
49:                 Integer max = config.configuration().maxThreads().get();
52:                     throw new MaximumThreadsException( max );
71:         int prefered = config.configuration().preferedNumberOfThreads().get();
github.com/google/skylark:eval.go: [ master, ]
29: type Thread struct {
26: // A Thread contains the state of a Skylark thread,
27: // such as its call stack and thread-local storage.
28: // The Thread is threaded throughout the evaluator.
36: 	Print func(thread *Thread, msg string)
44: 	Load func(thread *Thread, module string) (StringDict, error)
46: 	// locals holds arbitrary "thread-local" Go values belonging to the client.
51: // SetLocal sets the thread-local value associated with the specified key.
53: func (thread *Thread) SetLocal(key string, value interface{}) {
54: 	if thread.locals == nil {
55: 		thread.locals = make(map[string]interface{})
57: 	thread.locals[key] = value
60: // Local returns the thread-local value associated with the specified key.
61: func (thread *Thread) Local(key string) interface{} {
62: 	return thread.locals[key]
67: func (thread *Thread) Caller() *Frame { return thread.frame.parent }
70: func (thread *Thread) TopFrame() *Frame { return thread.frame }
117: // The Frames of a thread are structured as a spaghetti stack, not a
217: // Thread is the state associated with the Skylark thread.
231: func ExecFile(thread *Thread, filename string, src interface{}, predeclared StringDict) (StringDict, error) {
238: 	g, err := mod.Init(thread, predeclared)
280: func (prog *Program) Init(thread *Thread, predeclared StringDict) (StringDict, error) {
283: 	_, err := Call(thread, toplevel, nil, nil)
328: func Eval(thread *Thread, filename string, src interface{}, env StringDict) (Value, error) {
341: 	return Call(thread, fn, nil, nil)
724: 			needle, ok := x.(String)
728: 			return Bool(strings.Contains(string(y), string(needle))), nil
850: func Call(thread *Thread, fn Value, args Tuple, kwargs []Tuple) (Value, error) {
856: 	thread.frame = &Frame{parent: thread.frame, callable: c}
857: 	result, err := c.CallInternal(thread, args, kwargs)
858: 	thread.frame = thread.frame.parent
android.googlesource.com/platform/external/rust/crates/syn:1.0.7/src/lib.rs: [ master, ]
775: mod thread;
131: //!     bad: std::thread::Thread,
141: //! error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
144: //! 7 |     bad: std::thread::Thread,
145: //!   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `Thread`
255:     clippy::needless_doctest_main,
256:     clippy::needless_pass_by_value,
github.com/apache/commons-io:src/main/java/org/apache/commons/io/ThreadMonitor.java: [ master, ]
42:     private final Thread thread;
40: class ThreadMonitor implements Runnable {
94:     private ThreadMonitor(final Thread thread, final long timeout) {
20:  * Monitors a thread, interrupting it if it reaches the specified timeout.
23:  * interrupting the thread being monitored. If the thread being monitored
25:  * the <i>monitor</i> thread.
31:  *           Thread monitor = ThreadMonitor.start(timeoutInMillis);
46:      * Start monitoring the current thread.
50:      * @return The monitor thread or {@code null}
53:     public static Thread start(final long timeout) {
54:         return start(Thread.currentThread(), timeout);
58:      * Start monitoring the specified thread.
60:      * @param thread The thread The thread to monitor
63:      * @return The monitor thread or {@code null}
66:     public static Thread start(final Thread thread, final long timeout) {
67:         Thread monitor = null;
69:             final ThreadMonitor timout = new ThreadMonitor(thread, timeout);
70:             monitor = new Thread(timout, ThreadMonitor.class.getSimpleName());
78:      * Stop monitoring the specified thread.
80:      * @param thread The monitor thread, may be {@code null}
82:     public static void stop(final Thread thread) {
83:         if (thread != null) {
84:             thread.interrupt();
91:      * @param thread The thread to monitor
95:         this.thread = thread;
101:      * interrupt the thread being monitored.
109:             thread.interrupt();
118:      * This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else
119:      * it deems appropriate. Read the docs on Thread.sleep for further interesting details.
128:             Thread.sleep(remaining);
33:  *           ThreadMonitor.stop(monitor);
android.googlesource.com/platform/system/nfc:src/adaptation/NfcAdaptation.cc: [ master, ]
438: uint32_t NfcAdaptation::Thread(__attribute__((unused)) uint32_t arg) {
796: ThreadMutex::ThreadMutex() {
846: ThreadCondVar::ThreadCondVar() {
813: ThreadMutex::~ThreadMutex() { pthread_mutex_destroy(&mMutex); }
864: ThreadCondVar::~ThreadCondVar() { pthread_cond_destroy(&mCondVar); }
903: AutoThreadMutex::AutoThreadMutex(ThreadMutex& m) : mm(m) { mm.lock(); }
914: AutoThreadMutex::~AutoThreadMutex() { mm.unlock(); }
262:   // Android already logs thread_id, proc_id, timestamp, so disable those.
343:     GKI_create_task((TASKPTR)Thread, MMI_TASK, (int8_t*)"NFCA_THREAD", nullptr, 0,
405: ** Description: signal the CondVar to release the thread that is waiting
431: ** Function:    NfcAdaptation::Thread()
439:   const char* func = "NfcAdaptation::Thread";
57: ThreadMutex NfcAdaptation::sLock;
60: ThreadCondVar NfcAdaptation::mHalOpenCompletedEvent;
61: ThreadCondVar NfcAdaptation::mHalCloseCompletedEvent;
278:     // of a byte array is ambiguous and needlessly difficult to configure.
340:                   (pthread_cond_t*)nullptr, nullptr);
344:                     (pthread_cond_t*)nullptr, nullptr);
433: ** Description: Creates work threads
443:     ThreadCondVar CondVar;
446:                     (pthread_cond_t*)CondVar, (pthread_mutex_t*)CondVar);
789: ** Function:    ThreadMutex::ThreadMutex()
797:   pthread_mutexattr_t mutexAttr;
799:   pthread_mutexattr_init(&mutexAttr);
800:   pthread_mutex_init(&mMutex, &mutexAttr);
801:   pthread_mutexattr_destroy(&mutexAttr);
806: ** Function:    ThreadMutex::~ThreadMutex()
817: ** Function:    ThreadMutex::lock()
824: void ThreadMutex::lock() { pthread_mutex_lock(&mMutex); }
828: ** Function:    ThreadMutex::unblock()
835: void ThreadMutex::unlock() { pthread_mutex_unlock(&mMutex); }
839: ** Function:    ThreadCondVar::ThreadCondVar()
847:   pthread_condattr_t CondAttr;
849:   pthread_condattr_init(&CondAttr);
850:   pthread_cond_init(&mCondVar, &CondAttr);
852:   pthread_condattr_destroy(&CondAttr);
857: ** Function:    ThreadCondVar::~ThreadCondVar()
868: ** Function:    ThreadCondVar::wait()
875: void ThreadCondVar::wait() {
876:   pthread_cond_wait(&mCondVar, *this);
877:   pthread_mutex_unlock(*this);
882: ** Function:    ThreadCondVar::signal()
889: void ThreadCondVar::signal() {
891:   pthread_cond_signal(&mCondVar);
168:   AutoThreadMutex a(sLock);
342:     AutoThreadMutex guard(mCondVar);
363:   AutoThreadMutex a(sLock);
444:     AutoThreadMutex guard(CondVar);
890:   AutoThreadMutex a(*this);
896: ** Function:    AutoThreadMutex::AutoThreadMutex()
907: ** Function:    AutoThreadMutex::~AutoThreadMutex()
android.googlesource.com/platform/external/rust/crates/syn:0.15.42/src/lib.rs: [ master, ]
570: mod thread;
132: //!     bad: std::thread::Thread,
142: //! error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
145: //! 7 |     bad: std::thread::Thread,
146: //!   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `Thread`
252:         needless_pass_by_value,
github.com/apache/xerces2-j:tests/thread/Test.java: [ trunk, ]
18: package thread;
657: class thread extends Thread {
661:     thread (ThreadInfo param) {
104: class ThreadInfo
111:     ThreadInfo() {
140: class ThreadParser extends HandlerBase
171: ThreadParser()
84:     int         numThreads;
109:     int        fThreadNum;      // Identifying number for this thread.
126: ThreadInfo      gThreadInfo[];
66:     int     checkSum;        // The XML checksum.  Set up by the main thread for
98: //  struct threadInfo  Holds information specific to an individual thread.
99: //                     One of these is set up for each thread in the test.
106:     boolean    fHeartBeat;      // Set true by the thread each time it finishes
577:         System.err.print("usage: java thread.Test [-v] [-threads nnn] [-time nnn] [-quiet] [-verbose] xmlfile...\n" +
600: //                          thread, before all of the worker threads are started.
649: //               thread termination.  Threads are stuck running here
651: //               main thread of the process (which never calls this
670:         System.out.println("Thread " + thInfo.fThreadNum + ": starting");
692:             System.out.println("Thread " + thInfo.fThreadNum +
726: } // class thread
796:         thread t = new thread(gThreadInfo[threadNum]);
803:     //                 display "." if some thread hasn't since previous "+"
811:             Thread.sleep(1000);
839:     //  To Do:  Run the main thread at higher priority, so that the worker threads
40:  * This program is a straight port of xerces/c/tests/ThreadTest.cpp
56: //                      and can safely be referenced by the test threads without
67:                              //   each file before the worker threads are started.
75: //                     During the test, the threads will access this info without
100: //                     The main program monitors the threads by looking
132: //  class ThreadParser   Bundles together a SAX parser and the SAX handlers
137: //                       in different threads.
168: //  ThreadParser constructor.  Invoked by the threads of the test program
263: //  addToCheckSum - private function, used within ThreadParser in
275: //  addToCheckSum - private function, used within ThreadParser in
468: } // class ThreadParser
516:             else if (argv[argnum].equals("-threads"))
583:             "     -threads nnn   Number of threads.  Default is 2. \n" +
644: //  threadMain   The main function for each of the swarm of test threads.
659:     ThreadInfo thInfo;
667:     ThreadParser thParser = null;
682:             thParser = new ThreadParser();
701:             System.err.println("\nThread " + thInfo.fThreadNum +
747:     // While we are still single threaded, parse each of the documents
751:     ThreadParser mainParser = new ThreadParser();
783:     //  Fire off the requested number of parallel threads
789:     gThreadInfo = new ThreadInfo[gRunInfo.numThreads];
791:     int threadNum;
792:     for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
794:         gThreadInfo[threadNum] = new ThreadInfo();
795:         gThreadInfo[threadNum].fThreadNum = threadNum;
801:     //  Loop, watching the heartbeat of the worker threads.
802:     //    Each second, display "+" when all threads have completed a parse
819:             for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
821:                 if (gThreadInfo[threadNum].fHeartBeat == false)
830:                 for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
831:                     gThreadInfo[threadNum].fHeartBeat = false;
838:     //  Tally up the total number of parses completed by each of the threads.
843:     for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
845:         totalParsesCompleted += gThreadInfo[threadNum].fParses;
853:     //  The threads are still running; we just return
114:         fThreadNum = -1;
487:     gRunInfo.numThreads = 2;
522:                     gRunInfo.numThreads = Integer.parseInt(argv[argnum]);
527:                 if (gRunInfo.numThreads < 0)
786:     if (gRunInfo.numThreads == 0)
github.com/kubernetes/minikube:site/themes/docsy/userguide/package-lock.json: [ master, ]
1098:             "needle": "^2.2.1",
1079:         "needle": {
github.com/kubernetes/minikube:site/package-lock.json: [ master, ]
1098:             "needle": "^2.2.1",
1079:         "needle": {
github.com/tensorflow/playground:package-lock.json: [ master, ]
1628:             "needle": "^2.2.1",
1609:         "needle": {
github.com/google/j2objc:jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/CompletableFuture.java: [ master, ]
1695:         volatile Thread thread;
406:     static final class ThreadPerTaskExecutor implements Executor {
2660:             public Thread newThread(Runnable r) {
2659:         static final class DaemonThreadFactory implements ThreadFactory {
62:  * <em>non-async</em> methods may be performed by the thread that
69:  * which case, a new Thread is created to run each task).
76:  * class maintains at most one daemon thread for triggering and
174:      *   invocation if already claimed by another thread.
407:         public void execute(Runnable r) { new Thread(r).start(); }
530:          * thread claims ownership.  If async, starts as task -- a
1684:      * Completion for recording and releasing a waiting thread.  This
1698:             this.thread = Thread.currentThread();
1704:             Thread w; // no need to atomically claim
1705:             if ((w = thread) != null) {
1706:                 thread = null;
1712:             if (Thread.interrupted())
1718:                     thread == null);
1729:         final boolean isLive() { return thread != null; }
1761:             q.thread = null;
1766:                     Thread.currentThread().interrupt();
1779:         if (Thread.interrupted())
1805:                 q.thread = null;
1918:      * @throws InterruptedException if the current thread was interrupted
1935:      * @throws InterruptedException if the current thread was interrupted
2421:      * parallel thread, or else an Executor using one thread per async
2423:      * an Executor that provides at least one independent thread.
2661:                 Thread t = new Thread(r);
51:  * <p>When two or more threads attempt to
195:      * linked). Multiple threads can call postComplete, which
203:      * that wake up waiting threads.  The mechanics are similar to
213:      * threads nulling out fields.  We also try to unlink fired
216:      * volatile because they are only visible to other threads upon
403:         ForkJoinPool.commonPool() : new ThreadPerTaskExecutor();
1743:                 if (ThreadLocalRandom.nextSecondarySeed() >= 0)
2668:         static final ScheduledThreadPoolExecutor delayer;
2670:             (delayer = new ScheduledThreadPoolExecutor(
2671:                 1, new DaemonThreadFactory())).
github.com/google/guava:guava/src/com/google/common/util/concurrent/AbstractFuture.java: [ master, ]
181:     volatile @Nullable Thread thread;
1178:     abstract void putThread(Waiter waiter, Thread newValue);
1248:     void putThread(Waiter waiter, Thread newValue) {
1298:     void putThread(Waiter waiter, Thread newValue) {
1331:     void putThread(Waiter waiter, Thread newValue) {
1204:     static final long WAITER_THREAD_OFFSET;
1278:     final AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater;
147:                 newUpdater(Waiter.class, Thread.class, "thread"),
192:       ATOMIC_HELPER.putThread(this, Thread.currentThread());
203:       // unpark even though the thread has already removed itself from the list. But even if we did
205:       Thread w = thread;
207:         thread = null;
219:    *   <li>This is only called when a waiting thread times out or is interrupted. Both of which
225:     node.thread = null; // mark as 'deleted'
236:         if (curr.thread != null) { // we aren't unlinking this node, update pred.
240:           if (pred.thread == null) { // We raced with another node that unlinked pred. Restart.
374:   //   have observed 12 micros on 64 bit linux systems to wake up a parked thread). So if the
391:    * current thread is interrupted during the call, even if the value is already available.
403:     if (Thread.interrupted()) {
423:               if (Thread.interrupted()) {
438:                 // Remove the waiter, one way or another we are done parking this thread.
458:       if (Thread.interrupted()) {
502:    * current thread is interrupted during the call, even if the value is already available.
509:     if (Thread.interrupted()) {
526:             if (Thread.interrupted()) {
918:         Thread.currentThread().interrupt();
1143:     // arbitrary cycles using a thread local but this should be a good enough solution (it is also
1177:     /** Non volatile write of the thread to the {@link Waiter#thread} field. */
1238:         WAITER_THREAD_OFFSET = unsafe.objectFieldOffset(Waiter.class.getDeclaredField("thread"));
1249:       UNSAFE.putObject(waiter, WAITER_THREAD_OFFSET, newValue);
1285:         AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater,
1332:       waiter.thread = newValue;
357:   /** All waiting threads. */
923:   /** Unblocks all threads and runs all listeners. */
1023:   /** Releases all threads in the {@link #waiters} list, and clears the list. */
1290:       this.waiterThreadUpdater = waiterThreadUpdater;
1299:       waiterThreadUpdater.lazySet(waiter, newValue);
github.com/google/guava:android/guava/src/com/google/common/util/concurrent/AbstractFuture.java: [ master, ]
181:     @NullableDecl volatile Thread thread;
1179:     abstract void putThread(Waiter waiter, Thread newValue);
1249:     void putThread(Waiter waiter, Thread newValue) {
1299:     void putThread(Waiter waiter, Thread newValue) {
1332:     void putThread(Waiter waiter, Thread newValue) {
1205:     static final long WAITER_THREAD_OFFSET;
1279:     final AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater;
147:                 newUpdater(Waiter.class, Thread.class, "thread"),
192:       ATOMIC_HELPER.putThread(this, Thread.currentThread());
203:       // unpark even though the thread has already removed itself from the list. But even if we did
205:       Thread w = thread;
207:         thread = null;
219:    *   <li>This is only called when a waiting thread times out or is interrupted. Both of which
225:     node.thread = null; // mark as 'deleted'
236:         if (curr.thread != null) { // we aren't unlinking this node, update pred.
240:           if (pred.thread == null) { // We raced with another node that unlinked pred. Restart.
374:   //   have observed 12 micros on 64 bit linux systems to wake up a parked thread). So if the
391:    * current thread is interrupted during the call, even if the value is already available.
403:     if (Thread.interrupted()) {
423:               if (Thread.interrupted()) {
438:                 // Remove the waiter, one way or another we are done parking this thread.
458:       if (Thread.interrupted()) {
502:    * current thread is interrupted during the call, even if the value is already available.
509:     if (Thread.interrupted()) {
526:             if (Thread.interrupted()) {
918:         Thread.currentThread().interrupt();
1144:     // arbitrary cycles using a thread local but this should be a good enough solution (it is also
1178:     /** Non volatile write of the thread to the {@link Waiter#thread} field. */
1239:         WAITER_THREAD_OFFSET = unsafe.objectFieldOffset(Waiter.class.getDeclaredField("thread"));
1250:       UNSAFE.putObject(waiter, WAITER_THREAD_OFFSET, newValue);
1286:         AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater,
1333:       waiter.thread = newValue;
357:   /** All waiting threads. */
923:   /** Unblocks all threads and runs all listeners. */
1023:   /** Releases all threads in the {@link #waiters} list, and clears the list. */
1291:       this.waiterThreadUpdater = waiterThreadUpdater;
1300:       waiterThreadUpdater.lazySet(waiter, newValue);
github.com/google/binnavi:debug/client/windynamorio/drdebug.proto: [ master, ]
347:   optional uint64 thread  = 5; // required
54:     SUSPEND_THREAD        = 9;
55:     RESUME_THREAD         = 10;
75:   repeated uint64 thread_id = 2;
185:     UNKNOWN_THREAD             = 12;
232:   repeated uint64 thread_id = 1;
306:     THREAD_CREATED   = 2;
307:     THREAD_EXITED    = 3;
318:   optional ThreadCreatedInfo   thread_created_info   = 3;
319:   optional ThreadExitedInfo    thread_exited_info    = 4;
330:   optional uint64 thread_id = 3; // required
334:   optional uint64 thread_id = 1; // required
338:   optional uint64 thread_id = 1; // required
357:   optional uint64 thread_id    = 3; // required
365:   optional uint64 thread_id = 1; // required
333: message ThreadCreatedInfo {
337: message ThreadExitedInfo {
84:   optional SuspendThreadArgs       suspend_thread_args        = 9;
85:   optional ResumeThreadArgs        resume_thread_args         = 10;
206:   optional SuspendThreadResult       suspend_thread_result        = 9;
207:   optional ResumeThreadResult        resume_thread_result         = 10;
53:     LIST_THREADS          = 8;
83:   optional ListThreadsArgs         list_threads_args          = 8;
205:   optional ListThreadsResult         list_threads_result          = 8;
118: message ListThreadsArgs {
121: message SuspendThreadArgs {
124: message ResumeThreadArgs {
231: message ListThreadsResult {
235: message SuspendThreadResult {
238: message ResumeThreadResult {
52:     // thread control
74:   //       not all commands could be executed thread-locally (like write memory)
186:     // Someone tried to resume already running thread.
72:   // execute the command only on those threads
github.com/chromium/chromium:sandbox/win/src/nt_internals.h: [ master, ]
814:   HANDLE thread;
42: #define CURRENT_THREAD ((HANDLE)-2)
270:   PVOID UniqueThread;
286:   ThreadBasicInformation,
287:   ThreadTimes,
288:   ThreadPriority,
289:   ThreadBasePriority,
290:   ThreadAffinityMask,
291:   ThreadImpersonationToken,
292:   ThreadDescriptorTableEntry,
293:   ThreadEnableAlignmentFaultFixup,
294:   ThreadEventPair,
295:   ThreadQuerySetWin32StartAddress,
296:   ThreadZeroTlsCell,
297:   ThreadPerformanceCount,
298:   ThreadAmILastThread,
299:   ThreadIdealProcessor,
300:   ThreadPriorityBoost,
301:   ThreadSetTlsArrayAddress,
302:   ThreadIsIoPending,
303:   ThreadHideFromDebugger
285: typedef enum _NT_THREAD_INFORMATION_CLASS {
304: } NT_THREAD_INFORMATION_CLASS,
305:     *PNT_THREAD_INFORMATION_CLASS;
273: typedef NTSTATUS(WINAPI* NtOpenThreadFunction)(OUT PHANDLE ThreadHandle,
307: typedef NTSTATUS(WINAPI* NtSetInformationThreadFunction)(
377: typedef NTSTATUS(WINAPI* NtOpenThreadTokenFunction)(IN HANDLE ThreadHandle,
383: typedef NTSTATUS(WINAPI* NtOpenThreadTokenExFunction)(IN HANDLE ThreadHandle,
408: typedef NTSTATUS(WINAPI* RtlCreateUserThreadFunction)(
266: // Process and Thread
309:     IN NT_THREAD_INFORMATION_CLASS ThreadInformationClass,
417:     OUT PHANDLE Thread,
308:     IN HANDLE ThreadHandle,
310:     IN PVOID ThreadInformation,
311:     IN ULONG ThreadInformationLength);
410:     IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
415:     IN LPTHREAD_START_ROUTINE StartAddress,
github.com/google/binnavi:debug/client/defs.hpp: [ master, ]
232: struct Thread {
247:   Thread(unsigned int tid, ThreadState state)
136: enum ThreadState {
264:   typedef std::function<bool(const Thread&)> ThreadComparator;
586:   std::vector<Thread> threads;
589:   void addThread(const Thread& thread) {
158:   dbgevt_thread_created,
161:   dbgevt_thread_closed,
266:   static ThreadComparator MakeThreadIdComparator(int tid) {
593:   std::vector<Thread> getThreads() const {
135: // Identifies the state of a thread
137:   // Thread is running
140:   // Thread is suspended
157:   // A new thread was created in the target process
160:   // An existing thread was closed in the target process
230:  * Describes a thread of the target process
233:   //  The thread ID of the thread
236:   // The state of the thread
242:    * Creates a new Thread object
244:    * @param tid The thread ID of the thread
245:    * @param state The state of the thread
252:   bool operator==(const Thread& rhs) const {
256:   bool operator<(const Thread& rhs) const {
261:    * Returns a function which matches the thread with a given id
267:     return [tid](const Thread& t)->bool {return t.tid == tid; };
414:   // Thread ID of the thread where the exception happened
590:     threads.push_back(thread);
717:       std::vector<Thread> threads = registers.getThreads();
719:       for (std::vector<Thread>::iterator Iter = threads.begin();
721:         Thread t = *Iter;
237:   ThreadState state;
594:     return threads;
720:           Iter != threads.end(); ++Iter) {
github.com/firebase/firebase-ios-sdk:Firebase/Messaging/Protos/GtalkCore.pbobjc.h: [ master, ]
809: @property(nonatomic, readwrite, copy, null_resettable) NSString *thread;
811: @property(nonatomic, readwrite) BOOL hasThread;
761:   GtalkMessageStanza_FieldNumber_Thread = 8,
810: /** Test to see if @c thread has been set. */
github.com/google/gapid:gapis/service/service.proto: [ master, ]
888: message Thread {
78: message Threads {
79:   repeated path.Thread list = 1;
101:     Thread thread = 18;
887: // Thread represents a single thread in the capture.
102:     Threads threads = 19;
github.com/libgit2/objective-git:External/libgit2/src/pack-objects.c: [ master, ]
1110: 	git_thread thread;
1109: struct thread_params {
1127: static void *threaded_find_deltas(void *arg)
183: unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n)
15: #include "thread-utils.h"
155: 	pb->nr_threads = 1; /* do not spawn any thread by default */
1129: 	struct thread_params *me = arg;
1143: 			git_error_set(GIT_ERROR_THREAD, "unable to lock packfile condition mutex");
1152: 		 * condition because the main thread may have set it to 1
1155: 		 * was initialized to 0 before this thread was spawned
1168: 	struct thread_params *p;
1219: 		ret = git_thread_create(&p[i].thread,
1222: 			git_error_set(GIT_ERROR_THREAD, "unable to create thread");
1229: 	 * Now let's wait for work completion.  Each time a thread is done
1231: 	 * thread with the largest number of unprocessed objects and give
1232: 	 * it to that newly idle thread.  This ensure good load balancing
1237: 		struct thread_params *target = NULL;
1238: 		struct thread_params *victim = NULL;
1241: 		/* Start by locating a thread that has transitioned its
1256: 		 * a thread to receive more work. We still need to locate a
1257: 		 * thread from which to steal work (the victim). */
1291: 			git_error_set(GIT_ERROR_THREAD, "unable to lock packfile condition mutex");
1301: 			git_thread_join(&target->thread, NULL);
50: #ifdef GIT_THREADS
62: #endif /* GIT_THREADS */
163: #ifdef GIT_THREADS
187: #ifdef GIT_THREADS
188: 	pb->nr_threads = n;
191: 	assert(1 == pb->nr_threads);
194: 	return pb->nr_threads;
1033: 		 * it anyway, and doing it here while we're threaded will
1034: 		 * save a lot of time in the non threaded write phase,
1107: #ifdef GIT_THREADS
1170: 	int ret, active_threads = 0;
1172: 	if (!pb->nr_threads)
1173: 		pb->nr_threads = git_online_cpus();
1175: 	if (pb->nr_threads <= 1) {
1180: 	p = git__mallocarray(pb->nr_threads, sizeof(*p));
1183: 	/* Partition the work among the threads */
1184: 	for (i = 0; i < pb->nr_threads; ++i) {
1185: 		size_t sub_size = list_size / (pb->nr_threads - i);
1188: 		if (sub_size < 2*window && i+1 < pb->nr_threads)
1211: 	/* Start work threads */
1212: 	for (i = 0; i < pb->nr_threads; ++i) {
1220: 					threaded_find_deltas, &p[i]);
1225: 		active_threads++;
1236: 	while (active_threads) {
1247: 			for (i = 0; !target && i < pb->nr_threads; i++)
1258: 		for (i = 0; i < pb->nr_threads; i++)
1304: 			active_threads--;
1773: #ifdef GIT_THREADS
chromium.googlesource.com/chromium/src/sandbox:win/src/nt_internals.h: [ master, ] Duplicate result
android.googlesource.com/platform/external/pthreads:implement.h: [ master, ]
130:   DWORD thread;
444:   ptw32_thread_t * thread;
131:   HANDLE threadH;		/* Win32 thread handle - POSIX thread is invalid if threadH == 0 */
139:   pthread_mutex_t threadLock;	/* Used for serialised access to public thread state */
210:   pthread_t ownerThread;
271:   void *threads;
275: typedef struct ThreadParms ThreadParms;
276: typedef struct ThreadKeyAssoc ThreadKeyAssoc;
278: struct ThreadParms
344: struct ThreadKeyAssoc
447:   ThreadKeyAssoc *nextThread;
449:   ThreadKeyAssoc *prevThread;
123: typedef struct ptw32_thread_t_ ptw32_thread_t;
125: struct ptw32_thread_t_
522: #define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *) 1)
162: struct pthread_attr_t_
198: struct pthread_mutex_t_
215: struct pthread_mutexattr_t_
242: struct pthread_spinlock_t_
252: struct pthread_barrier_t_
261: struct pthread_barrierattr_t_
266: struct pthread_key_t_
286: struct pthread_cond_t_
304: struct pthread_condattr_t_
311: struct pthread_rwlock_t_
322: struct pthread_rwlockattr_t_
108:   PThreadStateInitial = 0,	/* Thread not running                   */
109:   PThreadStateRunning,		/* Thread alive & kicking               */
110:   PThreadStateSuspended,	/* Thread alive but suspended           */
111:   PThreadStateCancelPending,	/* Thread alive but is                  */
113:   PThreadStateCanceling,	/* Thread alive but is                  */
116:   PThreadStateException,	/* Thread alive but exiting             */
118:   PThreadStateLast
120: PThreadState;
696: #define _beginthreadex(security, \
709: #define _endthreadex ExitThread
104:    * This enumeration represents the state of the thread;
105:    * The thread is still "alive" if the numeric value of the
132:   pthread_t ptHandle;		/* This thread's permanent pthread_t handle */
133:   ptw32_thread_t * prevReuse;	/* Links threads on reuse stack */
206:   int recursive_count;		/* Number of unlocks a thread needs to perform
348:    *      This structure creates an association between a thread and a key.
350:    *      destroy routine for thread specific data registered by a user upon
351:    *      exiting a thread.
357:    *         T - Thread that has called pthread_setspecific(Kn)
358:    *            (head of chain is thread->keys)
377:    *      general lock (guarding the row) and the thread's general
381:    *      be released - both the key must be deleted and the thread
383:    *      allows the resources to be freed as soon as either thread or
387:    *      and thread locks are always acquired in the order: key lock
388:    *      then thread lock. An exception to this exists when a thread
392:    *      An association is created when a thread first calls
397:    *      thread calls the key destructor function on thread exit, or
401:    *      thread
402:    *              reference to the thread that owns the
404:    *              thread struct itself. Since the association is
405:    *              destroyed before the thread exits, this can never
406:    *              point to a different logical thread to the one that
407:    *              created the assoc, i.e. after thread struct reuse.
434:    *      1)      As soon as either the key or the thread is no longer
521: /* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
525: extern ptw32_thread_t * ptw32_threadReuseTop;
526: extern ptw32_thread_t * ptw32_threadReuseBottom;
540: extern CRITICAL_SECTION ptw32_thread_reuse_lock;
595:   void ptw32_threadReusePush (pthread_t thread);
599:   int ptw32_setthreadpriority (pthread_t thread, int policy, int priority);
610:   void ptw32_callUserDestroyRoutines (pthread_t thread);
612:   int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key);
6:  * Keeps all the internals out of pthread.h
10:  *      Pthreads-win32 - POSIX Threads Library for Win32
141:   pthread_mutex_t cancelLock;	/* Used for async-cancel safety */
188:   pthread_mutex_t lock;
212: 				   threads. */
248:     pthread_mutex_t mutex;	/* mutex if single cpu.            */
270:   pthread_mutex_t keyLock;
280:   pthread_t tid;
288:   long nWaitersBlocked;		/* Number of threads blocked            */
289:   long nWaitersGone;		/* Number of threads timed out          */
290:   long nWaitersToUnblock;	/* Number of threads to unblock         */
291:   sem_t semBlockQueue;		/* Queue up threads waiting for the     */
296:   pthread_mutex_t mtxUnblockLock;	/* Mutex that guards access to          */
299:   pthread_cond_t next;		/* Doubly linked list                   */
300:   pthread_cond_t prev;
313:   pthread_mutex_t mtxExclusiveAccess;
314:   pthread_mutex_t mtxSharedAccessCompleted;
315:   pthread_cond_t cndSharedAccessCompleted;
356:    *            (head of chain is key->threads)
393:    *      pthread_setspecific() on a key that has a specified
413:    *              The pthread_t->keys attribute is the head of a
416:    *              between a pthread_t and all pthread_key_t on which
417:    *              it called pthread_setspecific.
422:    *      nextThread
423:    *              The pthread_key_t->threads attribute is the head of
426:    *              relationship between a pthread_key_t and all the 
427:    *              PThreads that have called pthread_setspecific for
428:    *              this pthread_key_t.
430:    *      prevThread
439:    *              pthread_setspecific if the user provided a
445:   pthread_key_t key;
446:   ThreadKeyAssoc *nextKey;
448:   ThreadKeyAssoc *prevKey;
518: /* Declared in pthread_cancel.c */
527: extern pthread_key_t ptw32_selfThreadKey;
528: extern pthread_key_t ptw32_cleanupKey;
529: extern pthread_cond_t ptw32_cond_list_head;
530: extern pthread_cond_t ptw32_cond_list_tail;
548: extern int pthread_count;
564:   int ptw32_is_attr (const pthread_attr_t * attr);
566:   int ptw32_cond_check_need_init (pthread_cond_t * cond);
567:   int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
568:   int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
581: 			       HANDLE threadH, DWORD callback_arg);
587:   void ptw32_threadDestroy (pthread_t tid);
591:   pthread_t ptw32_new (void);
593:   pthread_t ptw32_threadReusePop (void);
608:     ptw32_threadStart (void *vthreadParms);
614:   void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
649:   _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
651:   _CRTIMP void __cdecl _endthread (void);
689: #if defined(__CYGWIN32__) || defined(__CYGWIN__) || defined(NEED_CREATETHREAD)
692:  * Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE
702:         CreateThread(security, \
704:                      (LPTHREAD_START_ROUTINE) start_proc, \
711: #endif				/* __CYGWIN32__ || __CYGWIN__ || NEED_CREATETHREAD */
12:  *      Copyright(C) 1999,2005 Pthreads-win32 contributors
20:  *      http://sources.redhat.com/pthreads-win32/contributors.html
106:    * state is greater or equal "PThreadStateRunning".
134:   volatile PThreadState state;
425:    *              nextThreads link. This chain provides the 1 to many
652:   _CRTIMP unsigned long __cdecl _beginthreadex (void *, unsigned,
655:   _CRTIMP void __cdecl _endthreadex (unsigned);
685:  * Question 1 - How do I get pthreads-win32 to link under Cygwin or Mingw32?
android.googlesource.com/platform/external/libchrome:base/debug/activity_tracker.h: [ master, ]
119:   } thread;
118:     int64_t thread_id;  // A unique identifier for a thread within a process.
279:     ACT_THREAD = 4 << 4,
594:     std::string thread_name;
604:     int64_t thread_id = 0;
751:   const PlatformThreadRef thread_id_;  // The thread this instance is bound to.
1208:   std::atomic<int> thread_tracker_count_;
1211:   ActivityTrackerMemoryAllocator thread_tracker_allocator_;
1212:   Lock thread_tracker_allocator_lock_;
160:   static ActivityData ForThread(const int64_t id) {
574: class BASE_EXPORT ThreadActivityTracker {
957:   ThreadActivityTracker* GetTrackerForCurrentThread() {
964:   ThreadActivityTracker* GetOrCreateTrackerForCurrentThread() {
1084:   class ThreadSafeUserData : public ActivityUserData {
280:     ACT_THREAD_START = ACT_THREAD,
281:     ACT_THREAD_JOIN,
1205:   ThreadLocalStorage::Slot this_thread_tracker_;
840:   class BASE_EXPORT ScopedThreadActivity
1076:     kMaxThreadCount = 100,
1077:     kCachedThreadMemories = 10,
1335: class BASE_EXPORT ScopedThreadJoinActivity
1339:   explicit ScopedThreadJoinActivity(const PlatformThreadHandle* thread)
36: #include "base/threading/platform_thread.h"
37: #include "base/threading/thread_local_storage.h"
162:     data.thread.thread_id = id;
184: // persistent memory allocator. Instances of this class are NOT thread-safe.
185: // Use from a single thread or protect access with a lock.
263:     // Task activities involve callbacks posted to a thread or thread-pool
278:     // Thread activities involve the life management of threads.
309:   // from a completely different thread though most activities will leave
345: // done by a thread by supporting key/value pairs of any type. This can provide
347: // global data. All updates must be done from the same thread though other
411:   // contents have been overwritten by another thread. The return value is
537:   // gone away (cleared by another thread/process), it will invalidate all the
565: // This class manages tracking a stack of activities for a single thread in
568: // thread is analyzing this data in real-time, atomic operations are used
578:   // This structure contains all the common information about the thread so
585:   // so that continued operation of the thread will not cause changes here.
592:     // The name of the thread as set when it was created. The name may be
599:     // The process and thread IDs. These values have no meaning other than
600:     // they uniquely identify a running process and a running thread within
601:     // that process.  Thread-IDs can be re-used across different processes
602:     // and both can be re-used after the process/thread exits.
606:     // The current stack of activities that are underway for this thread. It
635:     // The thread tracker to which this object reports. It can be null if
748:   // The ActivityTracker is thread bound, and will be invoked across all the
749:   // sequences that run on the thread. A ThreadChecker does not work here, as it
761: // The global tracker manages all the individual thread trackers. Memory for
762: // the thread trackers is taken from a PersistentMemoryAllocator which allows
837:   // This is a thin wrapper around the thread-tracker's ScopedActivity that
838:   // allows thread-safe access to data values. It is safe to use even if
854:     // Gets (or creates) a tracker for the current thread. If locking is not
857:     // the tracker for this thread has been created for other reasons, locks
858:     // will be tracked. The thread-tracker uses locks.
865:       // if code that runs late during thread destruction tries to use a
885:   // providing the given |stack_depth| to each thread tracker it manages. The
941:   // calling this. Tracking for the current thread will be automatically
953:   // Gets the thread's activity-tracker if it exists. This is inline for
954:   // performance reasons and it uses thread-local-storage (TLS) so that there
956:   // thread. Ownership remains with the global tracker.
958:     return reinterpret_cast<ThreadActivityTracker*>(this_thread_tracker_.Get());
961:   // Gets the thread's activity-tracker or creates one if none exists. This
971:   // Creates an activity-tracker for the current thread.
974:   // Releases the activity-tracker for the current thread (for testing only).
1039:   // Record field trial information. This call is thread-safe. In addition to
1050:   // Record exception information for the current thread.
1065:   // Updates to this are thread-safe.
1081:   // A wrapper around ActivityUserData that is thread-safe and thus can be used
1083:   // thread.
1145:   // A thin wrapper around the main thread-tracker that keeps additional
1154:     // The reference into persistent memory from which the thread-tracker's
1158:     // The physical address used for the thread-tracker's memory.
1166:   // providing the given |stack_depth| to each thread tracker it manages. The
1181:   // Releases the activity-tracker associcated with thread. It is called
1182:   // automatically when a thread is joined and thus there is nothing more to
1186:   // Does process-exit work. This can be run on any thread.
1204:   // The activity tracker for the currently executing thread.
1207:   // The number of thread trackers currently active.
1210:   // A caching memory allocator for thread-tracker objects.
1218:   // An object for holding arbitrary key value pairs with thread-safe access.
1239:   // the |background_task_runner_| if one is set or whatever thread reaped
1340:       : ScopedThreadJoinActivity(GetProgramCounter(), thread) {}
1344:                            const PlatformThreadHandle* thread);
9: // what all the various threads and processes are (or were) doing.
51: class ThreadActivityTracker;
159:   static ActivityData ForThread(const PlatformThreadHandle& handle);
348: // threads can read it concurrently if they create new objects using the same
624:     ScopedActivity(ThreadActivityTracker* tracker,
637:     ThreadActivityTracker* const tracker_;
646:   // A ThreadActivityTracker runs on top of memory that is managed externally.
649:   ThreadActivityTracker(void* base, size_t size);
650:   virtual ~ThreadActivityTracker();
738:   bool CalledOnValidThread();
757:   DISALLOW_COPY_AND_ASSIGN(ThreadActivityTracker);
841:       : public ThreadActivityTracker::ScopedActivity {
859:     static ThreadActivityTracker* GetOrCreateTracker(bool lock_allowed) {
867:       if (base::ThreadLocalStorage::HasBeenDestroyed())
871:         return global_tracker->GetOrCreateTrackerForCurrentThread();
873:         return global_tracker->GetTrackerForCurrentThread();
940:   // the global tracker completely. All tracked threads must exit before
965:     ThreadActivityTracker* tracker = GetTrackerForCurrentThread();
968:     return CreateTrackerForCurrentThread();
972:   ThreadActivityTracker* CreateTrackerForCurrentThread();
1074:     // The maximum number of threads that can be tracked within a process. If
1086:     ThreadSafeUserData(void* memory, size_t size, int64_t pid = 0);
1087:     ~ThreadSafeUserData() override;
1097:     DISALLOW_COPY_AND_ASSIGN(ThreadSafeUserData);
1146:   // information that the global tracker needs to handle joined threads.
1147:   class ManagedActivityTracker : public ThreadActivityTracker {
1196:   // The size (in bytes) of memory required by a ThreadActivityTracker to
1219:   ThreadSafeUserData process_data_;
45: class PlatformThreadHandle;
843:     ScopedThreadActivity(const void* program_counter,
848:     ~ScopedThreadActivity();
879:     DISALLOW_COPY_AND_ASSIGN(ScopedThreadActivity);
975:   void ReleaseTrackerForCurrentThreadForTesting();
1070:   friend class ScopedThreadActivity;
1249:     : public GlobalActivityTracker::ScopedThreadActivity {
1298:     : public GlobalActivityTracker::ScopedThreadActivity {
1310:     : public GlobalActivityTracker::ScopedThreadActivity {
1323:     : public GlobalActivityTracker::ScopedThreadActivity {
1336:     : public GlobalActivityTracker::ScopedThreadActivity {
1343:   ScopedThreadJoinActivity(const void* program_counter,
1345:   DISALLOW_COPY_AND_ASSIGN(ScopedThreadJoinActivity);
1351:     : public GlobalActivityTracker::ScopedThreadActivity {
chromium.googlesource.com/chromium/deps/psyco_win32:psyco/profiler.py: [ master, ]
20:     import dummy_thread as thread
365: def psyco_start_new_thread(callable, args, kw=None):
371: original_start_new_thread = thread.start_new_thread
358: def psyco_thread_stub(callable, args, kw):
18:     import thread
32: # a lock for a thread-safe go()
33: go_lock = thread.allocate_lock()
260:         self.lock = thread.allocate_lock()
343: # and thread.start_new_thread().
366:     "This is the Psyco-aware version of thread.start_new_thread()."
367:     return original_start_new_thread(psyco_thread_stub, (callable, args, kw))
374: thread.start_new_thread = psyco_start_new_thread
375: # hack to patch threading._start_new_thread if the module is
378:     hasattr(sys.modules['threading'], '_start_new_thread')):
379:     sys.modules['threading']._start_new_thread = psyco_start_new_thread
204:             alarm.stop(1)   # wait for parallel threads to stop
377: if ('threading' in sys.modules and
android.googlesource.com/platform/external/lzma:CPP/7zip/UI/Common/Bench.cpp: [ master, ]
694:   NWindows::CThread thread[2];
1512:   NWindows::CThread Thread;
1563:   NWindows::CThread Thread;
799:   HRESULT CreateEncoderThread()
804:   HRESULT CreateDecoderThread(unsigned index, bool callbackMode
695:   UInt32 NumDecoderSubThreads;
764:   static THREAD_FUNC_DECL EncodeThreadFunction(void *param)
786:   static THREAD_FUNC_DECL DecodeThreadFunction(void *param)
1141: static const UInt32 kNumThreadsMax = (1 << 12);
1526: static THREAD_FUNC_DECL FreqThreadFunction(void *param)
1542: struct CFreqThreads
1545:   UInt32 NumThreads;
1547:   CFreqThreads(): Items(NULL), NumThreads(0) {}
1554:   ~CFreqThreads()
1586: static THREAD_FUNC_DECL CrcThreadFunction(void *param)
1600: struct CCrcThreads
1603:   UInt32 NumThreads;
1605:   CCrcThreads(): Items(NULL), NumThreads(0) {}
1612:   ~CCrcThreads()
1867: AString GetProcessThreadsInfo(const NSystem::CProcessAffinity &ti)
2419: static UInt32 GetNumThreadsNext(unsigned i, UInt32 numThreads)
37: #include "../../../Windows/Thread.h"
801:     return thread[0].Create(EncodeThreadFunction, this);
819:     return thread[index].Create(DecodeThreadFunction, &decoder);
1313:       encoders[i].thread[0].Wait();
1386:         encoder.thread[j].Wait();
1403:         if (::GetThreadTimes(encoders[i].thread[j], &creationTime, &exitTime, &kernelTime, &userTime) != 0)
1521:     Thread.Wait();
1522:     Thread.Close();
1581:     Thread.Wait();
1582:     Thread.Close();
2166:       RINOK(info.Thread.Create(FreqThreadFunction, &info));
2302:       RINOK(info.Thread.Create(CrcThreadFunction, &info));
441:     ::GetThreadTimes(::GetCurrentThread()
1301:       RINOK(encoder.CreateEncoderThread())
1364:         HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0)
1427: static inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
1440:       (1 << 20) + (multiThread ? (6 << 20) : 0);
1934:     bool size_Defined, UInt64 size, const char *threadsString, UInt32 numThreads)
1953:   f.Print(threadsString);
2149:   CFreqThreads threads;
2152:     threads.Items = new CFreqInfo[numThreads];
2156:       CFreqInfo &info = threads.Items[i];
2165:       CFreqInfo &info = threads.Items[i];
2167:       threads.NumThreads++;
2169:     threads.WaitAll();
2172:       RINOK(threads.Items[i].CallbackRes);
2258:   CCrcThreads threads;
2261:     threads.Items = new CCrcInfo[numThreads];
2266:       CCrcInfo &info = threads.Items[i];
2301:       CCrcInfo &info = threads.Items[i];
2303:       threads.NumThreads++;
2305:     threads.WaitAll();
2308:       RINOK(threads.Items[i].Res);
2801:   NSystem::CProcessAffinity threadsInfo;
2802:   threadsInfo.InitST();
2806:   if (threadsInfo.Get() && threadsInfo.processAffinityMask != 0)
2807:     numCPUs = threadsInfo.GetNumProcessThreads();
3044:     PrintRequirements(*printCallback, "size: ", ramSize_Defined, ramSize, "CPU hardware threads:", numCPUs);
3045:     printCallback->Print(GetProcessThreadsInfo(threadsInfo));
3198:   // ---------- Threads loop ----------
3199:   for (unsigned threadsPassIndex = 0; threadsPassIndex < 3; threadsPassIndex++)
3206:     if (threadsPassIndex != 0)
3212:     if (threadsPassIndex != 0)
3217:       if (threadsPassIndex == 1)
3233:   if (threadsPassIndex > 0)
3263:   PrintRequirements(f, "usage:", true, GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads:   ", numThreads);
1063:       RINOK(setCoderMt->SetNumberOfThreads(NumDecoderSubThreads));
1170:         numThreads
1194:   UInt32 numEncoderThreads = 1;
1195:   UInt32 numSubDecoderThreads = 1;
1198:     numEncoderThreads = numThreads;
1202:       if (numThreads == 1 && method.Get_NumThreads() < 0)
1203:         method.AddProp_NumThreads(1);
1204:       const UInt32 numLzmaThreads = method.Get_Lzma_NumThreads();
1205:       if (numThreads > 1 && numLzmaThreads > 1)
1207:         numEncoderThreads = numThreads / 2;
1208:         numSubDecoderThreads = 2;
1213:   CBenchEncoders encodersSpec(numEncoderThreads);
1218:   for (i = 0; i < numEncoderThreads; i++)
1239:     for (UInt32 j = 0; j < numSubDecoderThreads; j++)
1257:   for (i = 0; i < numEncoderThreads; i++)
1273:   for (i = 0; i < numEncoderThreads; i++)
1290:       bpi->BenchInfo.NumIterations = numEncoderThreads;
1295:     if (numEncoderThreads > 1)
1311:   if (numEncoderThreads > 1)
1312:     for (i = 0; i < numEncoderThreads; i++)
1325:   for (i = 0; i < numEncoderThreads; i++)
1338:   UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads;
1340:   for (i = 0; i < numEncoderThreads; i++)
1349:       bpi->BenchInfo.NumIterations = numDecoderThreads;
1357:       int numSubThreads = method.Get_NumThreads();
1358:       encoder.NumDecoderSubThreads = (numSubThreads <= 0) ? 1 : numSubThreads;
1360:     if (numDecoderThreads > 1)
1362:       for (UInt32 j = 0; j < numSubDecoderThreads; j++)
1366:             , ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF
1381:   if (numDecoderThreads > 1)
1382:     for (i = 0; i < numEncoderThreads; i++)
1383:       for (UInt32 j = 0; j < numSubDecoderThreads; j++)
1398:   if (numDecoderThreads > 1)
1399:     for (i = 0; i < numEncoderThreads; i++)
1400:       for (UInt32 j = 0; j < numSubDecoderThreads; j++)
1411:   info.NumIterations = numSubDecoderThreads * encoders[0].NumIterations;
1413:   for (i = 0; i < numEncoderThreads; i++)
1443: UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench)
1447:   bool lzmaMt = (totalBench || numThreads > 1);
1448:   UInt32 numBigThreads = numThreads;
1450:     numBigThreads /= 2;
1452:     GetLZMAUsage(lzmaMt, dictionary) + (2 << 20)) * numBigThreads;
1550:     for (UInt32 i = 0; i < NumThreads; i++)
1552:     NumThreads = 0;
1608:     for (UInt32 i = 0; i < NumThreads; i++)
1610:     NumThreads = 0;
1870:   // s.Add_UInt32(ti.numProcessThreads);
1873:     // if (ti.numProcessThreads != ti.numSysThreads)
1876:       s.Add_UInt32(ti.GetNumSystemThreads());
1954:   PrintNumber(f, numThreads, 3);
2068:     UInt32 numThreads,
2097:         false, numThreads, method,
2122:     UInt32 numThreads,
2134:   if (numThreads == 0)
2135:     numThreads = 1;
2138:   numThreads = 1;
2150:   if (numThreads > 1)
2154:     for (i = 0; i < numThreads; i++)
2163:     for (i = 0; i < numThreads; i++)
2170:     for (i = 0; i < numThreads; i++)
2198:       UInt64 numCommands = (UInt64)numIterations * bufferSize * numThreads * complexity;
2200:       cpuFreq = rating / numThreads;
2217:     UInt32 numThreads, UInt32 bufferSize,
2226:   if (numThreads == 0)
2227:     numThreads = 1;
2230:   numThreads = 1;
2242:   size_t totalSize = (size_t)bufferSize * numThreads;
2243:   if (totalSize / numThreads != bufferSize)
2259:   if (numThreads > 1)
2264:     for (i = 0; i < numThreads; i++)
2299:     for (i = 0; i < numThreads; i++)
2306:     for (i = 0; i < numThreads; i++)
2335:   UInt64 unpSizeThreads = unpSize * numThreads;
2336:   info.UnpackSize = unpSizeThreads;
2337:   info.PackSize = unpSizeThreads;
2343:       UInt64 numCommands = unpSizeThreads * complexity / 256;
2352:   speed = info.GetSpeed(unpSizeThreads);
2360:     UInt32 numThreads, UInt32 bufSize,
2382:         numThreads, bufSize,
2425:   return (num <= numThreads) ? num : numThreads;
2815:   UInt32 numThreadsSpecified = numCPUs;
2821:   bool multiThreadTests = false;
2905:         multiThreadTests = true;
2909:       RINOK(ParseMtProp(s, propVariant, numCPUs, numThreadsSpecified));
3049:   if (numThreadsSpecified < 1 || numThreadsSpecified > kNumThreadsMax)
3067:         true, numThreadsSpecified,
3125:     unsigned numThreadsTests = 0;
3128:       UInt32 t = GetNumThreadsNext(numThreadsTests, numThreadsSpecified);
3130:       numThreadsTests++;
3131:       if (t >= numThreadsSpecified)
3136:     CTempValues speedTotals(numThreadsTests);
3138:       for (unsigned ti = 0; ti < numThreadsTests; ti++)
3158:         for (unsigned ti = 0; ti < numThreadsTests; ti++)
3161:           UInt32 t = GetNumThreadsNext(ti, numThreadsSpecified);
3179:       for (unsigned ti = 0; ti < numThreadsTests; ti++)
3202:   UInt32 numThreads = numThreadsSpecified;
3204:   if (!multiThreadTests)
3211:     numThreads = 1;
3216:       numThreads = numCPUs;
3220:           numThreads = numCPUs / 2;
3250:       if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize)
3361:         RINOK(FreqBench(complexInCommands, numThreads, printCallback,
3380:             complexInCommands, numThreads,
3388:       res = TotalBench_Hash(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads,
3397:         RINOK(FreqBench(complexInCommands, numThreads, printCallback,
3487:           true, numThreads,
github.com/apache/httpcomponents-client:httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java: [ master, ]
858:         private final Thread thread;
216:     private ThreadFactory threadFactory;
431:     public final H2AsyncClientBuilder setThreadFactory(final ThreadFactory threadFactory) {
552:      * connection pool using a background thread.
555:      * in order to stop and release the background thread.
861:             this.thread = new DefaultThreadFactory("idle-connection-evictor", true).newThread(new Runnable() {
865:                         while (!Thread.currentThread().isInterrupted()) {
866:                             Thread.sleep(maxIdleTime.toMillis());
870:                         Thread.currentThread().interrupt();
879:             thread.start();
883:             thread.interrupt();
39: import java.util.concurrent.ThreadFactory;
429:      * Assigns {@link ThreadFactory} instance.
432:         this.threadFactory = threadFactory;
722:                 threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
836:                 threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-main", true),
79: import org.apache.hc.core5.concurrent.DefaultThreadFactory;
chromium.googlesource.com/chromium/src:sandbox/win/src/nt_internals.h: [ master, ] Duplicate result
chromium.googlesource.com/ios-chromium-mirror:sandbox/win/src/nt_internals.h: [ master, ] Duplicate result
chromium.googlesource.com/arc/arc:third_party/chromium-ppapi/sandbox/win/src/nt_internals.h: [ master, ]
792:   HANDLE thread;
37: #define CURRENT_THREAD ((HANDLE)-2)
265:   PVOID UniqueThread;
281:   ThreadBasicInformation,
282:   ThreadTimes,
283:   ThreadPriority,
284:   ThreadBasePriority,
285:   ThreadAffinityMask,
286:   ThreadImpersonationToken,
287:   ThreadDescriptorTableEntry,
288:   ThreadEnableAlignmentFaultFixup,
289:   ThreadEventPair,
290:   ThreadQuerySetWin32StartAddress,
291:   ThreadZeroTlsCell,
292:   ThreadPerformanceCount,
293:   ThreadAmILastThread,
294:   ThreadIdealProcessor,
295:   ThreadPriorityBoost,
296:   ThreadSetTlsArrayAddress,
297:   ThreadIsIoPending,
298:   ThreadHideFromDebugger
280: typedef enum _NT_THREAD_INFORMATION_CLASS {
299: } NT_THREAD_INFORMATION_CLASS,
300:     *PNT_THREAD_INFORMATION_CLASS;
268: typedef NTSTATUS(WINAPI* NtOpenThreadFunction)(OUT PHANDLE ThreadHandle,
302: typedef NTSTATUS(WINAPI* NtSetInformationThreadFunction)(
360: typedef NTSTATUS(WINAPI* NtOpenThreadTokenFunction)(IN HANDLE ThreadHandle,
366: typedef NTSTATUS(WINAPI* NtOpenThreadTokenExFunction)(IN HANDLE ThreadHandle,
391: typedef NTSTATUS(WINAPI* RtlCreateUserThreadFunction)(
261: // Process and Thread
304:     IN NT_THREAD_INFORMATION_CLASS ThreadInformationClass,
400:     OUT PHANDLE Thread,
303:     IN HANDLE ThreadHandle,
305:     IN PVOID ThreadInformation,
306:     IN ULONG ThreadInformationLength);
393:     IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
398:     IN LPTHREAD_START_ROUTINE StartAddress,
android.googlesource.com/platform/superproject:development/samples/JetBoy/src/com/example/android/jetboy/JetBoyView.java: [ master, ]
1293:     private JetBoyThread thread;
125:     class JetBoyThread extends Thread implements OnJetEventListener {
286:         public JetBoyThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
1384:     public JetBoyThread getThread() {
215:         /** Message handler used by thread to interact with TextView */
433:             // JET info: inthis animation thread object. 
1027:          * Used to signal the thread whether it should be running or not.
1028:          * Passing true allows the thread to run; passing false will shut it
1227:             //this is how we send data back up to the main JetBoyView thread.
1270:             //events fire outside the animation thread. This can cause timing issues.
1271:             //put in queue for processing by animation thread.
1288:     }//end thread class
1292:     /** The thread that actually draws the animation */
1315:         // create thread only; it's started in surfaceCreated()
1318:             thread = new JetBoyThread(holder, context, new Handler() {
1372:             if (thread != null)
1373:                 thread.pause();
1380:      * Fetches the animation thread corresponding to this LunarView.
1382:      * @return the animation thread
1385:         return thread;
1391:         thread.setSurfaceSize(width, height);
1396:         // start the thread here so that we don't busy-wait in run()
1398:         thread.setRunning(true);
1399:         thread.start();
1405:         thread.setRunning(false);
1408:                 thread.join();
68:      * Base class for any external event passed to the JetBoyThread. This can
123:     // JET info: the JetBoyThread receives all the events from the JET player
android.googlesource.com/platform/external/jetbrains/JetBrainsRuntime:test/hotspot/jtreg/vmTestbase/nsk/share/jdwp/JDWP.java: [ master, ]
202:         public static final byte THREAD          = (byte)116;
40:         public static final int INVALID_THREAD                  = 10;
43:         public static final int THREAD_NOT_SUSPENDED            = 13;
44:         public static final int THREAD_SUSPENDED                = 14;
83:         public static final int UNATTACHED_THREAD               = 115;
113:         public static final byte THREAD_START    = (byte)6;
114:         public static final byte THREAD_END      = (byte)7;
115:         public static final byte THREAD_DEATH    = THREAD_END;
144:         public static final byte THREAD_ONLY    = (byte)3;
203:         public static final byte THREAD_GROUP    = (byte)103;
227:         public static final byte EVENT_THREAD    = (byte)1;
266:         public static int THREAD_ID         = OBJECT_ID;
267:         public static int THREAD_GROUP_ID   = OBJECT_ID;
155:     public static class ThreadStatus {
335:         public static final byte ThreadReference       = (byte)0x0B;
336:         public static final byte ThreadGroupReference  = (byte)0x0C;
479:         public static class ThreadReference {
485:             public static final int ThreadGroup         = 0x0B05;
500:         public static class ThreadGroupReference {
41:         public static final int INVALID_THREAD_GROUP            = 11;
234:         public static final int INVOKE_SINGLE_THREADED     = 0x01;
367:             public static final int AllThreads          = 0x0104;
368:             public static final int TopLevelThreadGroups  = 0x0105;
286:             THREAD_ID         = OBJECT_ID;
287:             THREAD_GROUP_ID   = OBJECT_ID;
734:                     case JDWP.Tag.THREAD:
735:                     case JDWP.Tag.THREAD_GROUP:
793:                     case JDWP.Tag.THREAD:
794:                     case JDWP.Tag.THREAD_GROUP:
849:                 case JDWP.Tag.THREAD:
850:                 case JDWP.Tag.THREAD_GROUP:
905:                     case JDWP.Tag.THREAD: {
906:                         type = "THREAD_ID";
908:                     case JDWP.Tag.THREAD_GROUP: {
909:                         type = "THREAD_GROUP_ID";
355:         commandNames.put(Command.ThreadReference.OwnedMonitorsStackDepthInfo, "ThreadReference.OwnedMonitorsStackDepthInfo");
356:         commandNames.put(Command.ThreadReference.ForceEarlyReturn, "ThreadReference.ForceEarlyReturn");
chromium.googlesource.com/chromium/src/base:debug/activity_tracker.h: [ master, ]
119:   } thread;
118:     int64_t thread_id;  // A unique identifier for a thread within a process.
279:     ACT_THREAD = 4 << 4,
594:     std::string thread_name;
604:     int64_t thread_id = 0;
751:   const PlatformThreadRef thread_id_;  // The thread this instance is bound to.
1198:   std::atomic<int> thread_tracker_count_;
1201:   ActivityTrackerMemoryAllocator thread_tracker_allocator_;
1202:   Lock thread_tracker_allocator_lock_;
160:   static ActivityData ForThread(const int64_t id) {
574: class BASE_EXPORT ThreadActivityTracker {
943:   ThreadActivityTracker* GetTrackerForCurrentThread() {
954:   ThreadActivityTracker* GetOrCreateTrackerForCurrentThread() {
1074:   class ThreadSafeUserData : public ActivityUserData {
280:     ACT_THREAD_START = ACT_THREAD,
281:     ACT_THREAD_JOIN,
1195:   ThreadLocalOwnedPointer<ThreadActivityTracker> this_thread_tracker_;
840:   class BASE_EXPORT ScopedThreadActivity
1066:     kMaxThreadCount = 100,
1067:     kCachedThreadMemories = 10,
1325: class BASE_EXPORT ScopedThreadJoinActivity
1329:   explicit ScopedThreadJoinActivity(const PlatformThreadHandle* thread)
36: #include "base/threading/platform_thread.h"
37: #include "base/threading/thread_local.h"
162:     data.thread.thread_id = id;
184: // persistent memory allocator. Instances of this class are NOT thread-safe.
185: // Use from a single thread or protect access with a lock.
263:     // Task activities involve callbacks posted to a thread or thread-pool
278:     // Thread activities involve the life management of threads.
309:   // from a completely different thread though most activities will leave
345: // done by a thread by supporting key/value pairs of any type. This can provide
347: // global data. All updates must be done from the same thread though other
411:   // contents have been overwritten by another thread. The return value is
537:   // gone away (cleared by another thread/process), it will invalidate all the
565: // This class manages tracking a stack of activities for a single thread in
568: // thread is analyzing this data in real-time, atomic operations are used
578:   // This structure contains all the common information about the thread so
585:   // so that continued operation of the thread will not cause changes here.
592:     // The name of the thread as set when it was created. The name may be
599:     // The process and thread IDs. These values have no meaning other than
600:     // they uniquely identify a running process and a running thread within
601:     // that process.  Thread-IDs can be re-used across different processes
602:     // and both can be re-used after the process/thread exits.
606:     // The current stack of activities that are underway for this thread. It
635:     // The thread tracker to which this object reports. It can be null if
748:   // The ActivityTracker is thread bound, and will be invoked across all the
749:   // sequences that run on the thread. A ThreadChecker does not work here, as it
761: // The global tracker manages all the individual thread trackers. Memory for
762: // the thread trackers is taken from a PersistentMemoryAllocator which allows
837:   // This is a thin wrapper around the thread-tracker's ScopedActivity that
838:   // allows thread-safe access to data values. It is safe to use even if
854:     // Gets (or creates) a tracker for the current thread. If locking is not
857:     // the tracker for this thread has been created for other reasons, locks
858:     // will be tracked. The thread-tracker uses locks.
879:   // providing the given |stack_depth| to each thread tracker it manages. The
927:   // calling this. Tracking for the current thread will be automatically
939:   // Gets the thread's activity-tracker if it exists. This is inline for
940:   // performance reasons and it uses thread-local-storage (TLS) so that there
942:   // thread. Ownership remains with the global tracker.
948:     return this_thread_tracker_.Get();
951:   // Gets the thread's activity-tracker or creates one if none exists. This
961:   // Creates an activity-tracker for the current thread.
964:   // Releases the activity-tracker for the current thread (for testing only).
1029:   // Record field trial information. This call is thread-safe. In addition to
1040:   // Record exception information for the current thread.
1055:   // Updates to this are thread-safe.
1071:   // A wrapper around ActivityUserData that is thread-safe and thus can be used
1073:   // thread.
1135:   // A thin wrapper around the main thread-tracker that keeps additional
1144:     // The reference into persistent memory from which the thread-tracker's
1148:     // The physical address used for the thread-tracker's memory.
1156:   // providing the given |stack_depth| to each thread tracker it manages. The
1171:   // Releases the activity-tracker associcated with thread. It is called
1172:   // automatically when a thread is joined and thus there is nothing more to
1176:   // Does process-exit work. This can be run on any thread.
1194:   // The activity tracker for the currently executing thread.
1197:   // The number of thread trackers currently active.
1200:   // A caching memory allocator for thread-tracker objects.
1208:   // An object for holding arbitrary key value pairs with thread-safe access.
1229:   // the |background_task_runner_| if one is set or whatever thread reaped
1330:       : ScopedThreadJoinActivity(GetProgramCounter(), thread) {}
1334:                            const PlatformThreadHandle* thread);
9: // what all the various threads and processes are (or were) doing.
51: class ThreadActivityTracker;
159:   static ActivityData ForThread(const PlatformThreadHandle& handle);
348: // threads can read it concurrently if they create new objects using the same
624:     ScopedActivity(ThreadActivityTracker* tracker,
637:     ThreadActivityTracker* const tracker_;
646:   // A ThreadActivityTracker runs on top of memory that is managed externally.
649:   ThreadActivityTracker(void* base, size_t size);
650:   virtual ~ThreadActivityTracker();
738:   bool CalledOnValidThread();
757:   DISALLOW_COPY_AND_ASSIGN(ThreadActivityTracker);
841:       : public ThreadActivityTracker::ScopedActivity {
859:     static ThreadActivityTracker* GetOrCreateTracker(bool lock_allowed) {
865:         return global_tracker->GetOrCreateTrackerForCurrentThread();
867:         return global_tracker->GetTrackerForCurrentThread();
926:   // the global tracker completely. All tracked threads must exit before
945:     if (base::ThreadLocalStorage::HasBeenDestroyed())
955:     ThreadActivityTracker* tracker = GetTrackerForCurrentThread();
958:     return CreateTrackerForCurrentThread();
962:   ThreadActivityTracker* CreateTrackerForCurrentThread();
1064:     // The maximum number of threads that can be tracked within a process. If
1076:     ThreadSafeUserData(void* memory, size_t size, int64_t pid = 0);
1077:     ~ThreadSafeUserData() override;
1087:     DISALLOW_COPY_AND_ASSIGN(ThreadSafeUserData);
1136:   // information that the global tracker needs to handle joined threads.
1137:   class ManagedActivityTracker : public ThreadActivityTracker {
1186:   // The size (in bytes) of memory required by a ThreadActivityTracker to
1209:   ThreadSafeUserData process_data_;
45: class PlatformThreadHandle;
843:     ScopedThreadActivity(const void* program_counter,
848:     ~ScopedThreadActivity();
873:     DISALLOW_COPY_AND_ASSIGN(ScopedThreadActivity);
965:   void ReleaseTrackerForCurrentThreadForTesting();
1060:   friend class ScopedThreadActivity;
1239:     : public GlobalActivityTracker::ScopedThreadActivity {
1288:     : public GlobalActivityTracker::ScopedThreadActivity {
1300:     : public GlobalActivityTracker::ScopedThreadActivity {
1313:     : public GlobalActivityTracker::ScopedThreadActivity {
1326:     : public GlobalActivityTracker::ScopedThreadActivity {
1333:   ScopedThreadJoinActivity(const void* program_counter,
1335:   DISALLOW_COPY_AND_ASSIGN(ScopedThreadJoinActivity);
1341:     : public GlobalActivityTracker::ScopedThreadActivity {
chromium.googlesource.com/playground/chromium-org-site:developers/sublime-text/compile_current_file.py: [ master, ]
17:   thread = None
16:   # static thread so that we don't try to run more than once at a time.
22:     self.thread_id = threading.current_thread().ident
35:     This must be called from the main UI thread (e.g., using set_timeout).
37:     assert self.thread_id == threading.current_thread().ident
64:     a Queue that we write to from another thread to avoid blocking on IO.
88:         # main thread.
102:     # Use a Queue to pass the text from the reading thread to this one.
104:     stdout_thread = threading.Thread(target=EnqueueOutput,
106:     stdout_thread.daemon = True  # Ensure this exits if the parent dies
107:     stdout_thread.start()
109:     # We use the self.interrupted flag to stop this thread.
128:         while stdout_thread.isAlive() or not stdout_queue.empty():
149:     Note that this command is a toggle, so if the thread is are already running,
157:     if self.thread and self.thread.is_alive():
159:       self.thread.join(5.0)
161:       self.thread = None
210:         self.thread = threading.Thread(target=self.execute_command,
212:         self.thread.start()
215:     logging.debug("Took %s seconds on UI thread to startup",
11: import threading
18:   lock = threading.Lock()
android.googlesource.com/platform/external/perfetto:src/trace_processor/trace_storage.h: [ master, ]
123:   struct Thread {
124:     explicit Thread(uint32_t t) : tid(t) {}
416:     const std::deque<int64_t>& thread_timestamp_ns() const {
419:     const std::deque<int64_t>& thread_duration_ns() const {
422:     const std::deque<int64_t>& thread_instruction_counts() const {
425:     const std::deque<int64_t>& thread_instruction_deltas() const {
451:     std::deque<int64_t> thread_timestamp_ns_;
452:     std::deque<int64_t> thread_duration_ns_;
453:     std::deque<int64_t> thread_instruction_counts_;
454:     std::deque<int64_t> thread_instruction_deltas_;
477:     const std::deque<int64_t>& thread_timestamp_ns() const {
480:     const std::deque<int64_t>& thread_duration_ns() const {
483:     const std::deque<int64_t>& thread_instruction_counts() const {
486:     const std::deque<int64_t>& thread_instruction_deltas() const {
512:     std::deque<int64_t> thread_timestamp_ns_;
513:     std::deque<int64_t> thread_duration_ns_;
514:     std::deque<int64_t> thread_instruction_counts_;
515:     std::deque<int64_t> thread_instruction_deltas_;
1114:   const tables::ThreadTrackTable& thread_track_table() const {
1128:   const tables::ThreadCounterTrackTable& thread_counter_track_table() const {
1176:   const ThreadSlices& thread_slices() const { return thread_slices_; }
1292:   size_t thread_count() const { return unique_threads_.size(); }
1327:   tables::ThreadTrackTable thread_track_table_{&string_pool_, &track_table_};
1331:   tables::ThreadCounterTrackTable thread_counter_track_table_{
1365:   ThreadSlices thread_slices_;
396:   class ThreadSlices {
963:   UniqueTid AddEmptyThread(uint32_t tid) {
985:   Thread* GetMutableThread(UniqueTid utid) {
1087:   virtual const Thread& GetThread(UniqueTid utid) const {
1117:   tables::ThreadTrackTable* mutable_thread_track_table() {
1131:   tables::ThreadCounterTrackTable* mutable_thread_counter_track_table() {
1177:   ThreadSlices* mutable_thread_slices() { return &thread_slices_; }
1359:   std::deque<Thread> unique_threads_;
398:     inline uint32_t AddThreadSlice(uint32_t slice_id,
438:     void UpdateThreadDeltasForSliceId(uint32_t slice_id,
499:     void UpdateThreadDeltasForSliceId(uint32_t slice_id,
103: // to read or search across a single field of the trace (e.g. all the thread
122:   // Information about a unique thread seen in a trace.
399:                                    int64_t thread_timestamp_ns,
400:                                    int64_t thread_duration_ns,
401:                                    int64_t thread_instruction_count,
402:                                    int64_t thread_instruction_delta) {
404:       thread_timestamp_ns_.emplace_back(thread_timestamp_ns);
405:       thread_duration_ns_.emplace_back(thread_duration_ns);
406:       thread_instruction_counts_.emplace_back(thread_instruction_count);
407:       thread_instruction_deltas_.emplace_back(thread_instruction_delta);
417:       return thread_timestamp_ns_;
420:       return thread_duration_ns_;
423:       return thread_instruction_counts_;
426:       return thread_instruction_deltas_;
439:                                       int64_t end_thread_timestamp_ns,
440:                                       int64_t end_thread_instruction_count) {
442:       int64_t begin_ns = thread_timestamp_ns_[row];
443:       thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns;
444:       int64_t begin_ticount = thread_instruction_counts_[row];
445:       thread_instruction_deltas_[row] =
446:           end_thread_instruction_count - begin_ticount;
460:                                          int64_t thread_timestamp_ns,
461:                                          int64_t thread_duration_ns,
462:                                          int64_t thread_instruction_count,
463:                                          int64_t thread_instruction_delta) {
465:       thread_timestamp_ns_.emplace_back(thread_timestamp_ns);
466:       thread_duration_ns_.emplace_back(thread_duration_ns);
467:       thread_instruction_counts_.emplace_back(thread_instruction_count);
468:       thread_instruction_deltas_.emplace_back(thread_instruction_delta);
478:       return thread_timestamp_ns_;
481:       return thread_duration_ns_;
484:       return thread_instruction_counts_;
487:       return thread_instruction_deltas_;
500:                                       int64_t end_thread_timestamp_ns,
501:                                       int64_t end_thread_instruction_count) {
503:       int64_t begin_ns = thread_timestamp_ns_[row];
504:       thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns;
505:       int64_t begin_ticount = thread_instruction_counts_[row];
506:       thread_instruction_deltas_[row] =
507:           end_thread_instruction_count - begin_ticount;
1088:     // Allow utid == 0 for idle thread retrieval.
1115:     return thread_track_table_;
1118:     return &thread_track_table_;
1129:     return thread_counter_track_table_;
1132:     return &thread_counter_track_table_;
1291:   // is reserved to indicate an invalid thread.
52: // UniqueTid is an offset into |unique_threads_|. Necessary because tids can
964:     unique_threads_.emplace_back(tid);
965:     return static_cast<UniqueTid>(unique_threads_.size() - 1);
986:     PERFETTO_DCHECK(utid < unique_threads_.size());
987:     return &unique_threads_[utid];
1089:     PERFETTO_DCHECK(utid < unique_threads_.size());
1090:     return unique_threads_[utid];
1290:   // |unique_threads_| always contains at least 1 element because the 0th ID
1364:   // Additional attributes for threads slices (sub-type of NestableSlices).
chromium.googlesource.com/private/55048997-blink2:LayoutTests/java/lc3/sources/com/netscape/javascript/qa/drivers/TestDriver.java: [ master, ]
57:     Thread THREAD = null;
90:         if ( THREAD == null ) {
91:             THREAD = new Thread(this);
92:             THREAD.start();
161:         if ( THREAD != null ) {
162:             THREAD.stop();
163:             THREAD = null;
864:      *  Temporary stop this thread for 5 seconds.
869:             THREAD.sleep( 5000 );
android.googlesource.com/platform/development:samples/JetBoy/src/com/example/android/jetboy/JetBoyView.java: [ master, ] Duplicate result
android.googlesource.com/platform/external/abseil-cpp:absl/synchronization/mutex.cc: [ master, ]
483:   PerThreadSynch *const thread;  // thread that is waiting
521: static PerThreadSynch *Synch_GetPerThread() {
509: static PerThreadSynch *const kPerThreadSynchNull =
526: static PerThreadSynch *Synch_GetPerThreadAnnotated(Mutex *mu) {
760: static inline PerThreadSynch *GetPerThreadSynch(intptr_t v) {
39: #include <thread>  // NOLINT(build/c++11)
51: #include "absl/base/internal/thread_identity.h"
56: #include "absl/synchronization/internal/per_thread_sem.h"
70: ABSL_ATTRIBUTE_WEAK void AbslInternalMutexYield() { std::this_thread::yield(); }
78: #if defined(THREAD_SANITIZER)
152:   // any thread to make progress gets it without undue delay.
448: // The SynchWaitParams struct encapsulates the way in which a thread is waiting:
451: // type of lock).  It also points to the PerThreadSynch struct of its thread.
455: // PerThreadSynch because a thread can be waiting on multiple Mutexes if,
461: // the thread is on a Mutex's waiter queue.
465:                   PerThreadSynch *thread_arg,
471:         thread(thread_arg),
475:   const Mutex::MuHow how;  // How this thread needs to wait.
476:   const Condition *cond;  // The condition that this thread is waiting for.
485:   // If not null, thread should be enqueued on the CondVar whose state
489:   int64_t contention_start_cycles;  // Time (in cycles) when this thread started
501:   // If a thread overfills the array during deadlock detection, we
504:   // detecting when a thread releases a lock it does not hold.
520: // Return the PerThreadSynch-struct for this thread.
523:   return &identity->per_thread_synch;
550:   PerThreadSem::Post(w->thread_identity());
577:   // Fix the per-thread state only if it exists.
580:     identity->per_thread_synch.suppress_fatal_errors = true;
617: // INVARIANT1:  there's a thread that was blocked on the mutex, is
622: // set when a thread is unblocked(INV1a), and threads that were
704: #ifdef THREAD_SANITIZER
764: // The next several routines maintain the per-thread next and skip fields
769: //   For thread x, x->skip is one of:
772: //     - a pointer to a distinct thread waiting later in the same Mutex queue
778: // first runnable thread y from the front a Mutex queue to adjust the skip
779: // field of another thread x because if x->skip==y, x->skip must (have) become
781: // thread from an arbitrary position in the queue whether runnable or not, so
790: // Returns the last thread y in a mutex waiter queue such that all threads in
793: // the range.  Requires thread x is in a mutex waiter queue.
851: // Enqueue thread "waitp->thread" on a waiter queue.
857: // If waitp->cv_word == nullptr, queue the thread at either the front or
863: // whether this thread was transferred from a CondVar or is waiting for a
867: // returned. This mechanism is used by CondVar to queue a thread on the
879:   PerThreadSynch *s = waitp->thread;
900:       // Every so often, update our idea of the thread's priority.
989: // Dequeue the successor pw->next of thread pw from the Mutex waiter queue
1052: // Try to remove thread s from the list of waiters on this mutex.
1065:       if ((w = pw->next) != s) {  // search for thread,
1076:           // don't search further if we found the thread, or we're about to
1077:           // process the first thread again.
1080:       if (w == s) {                 // found thread; remove it
1103: // Wait until thread "s", which must be the current thread, is removed from the
1136: // Wake thread w, and return the next thread in the list.
1187: // eventually followed by a call to LockLeave(mu, id, x) by the same thread.
1207:                      "thread releasing lock it does not hold: %p %s; "
1307: // Called in debug mode when a thread is about to acquire a lock in a way that
1324:     // it can't always be the first lock acquired by a thread.
1328:   // We prefer to keep stack traces that show a thread holding and acquiring
1334:   // For each other mutex already held by this thread:
1427:         ABSL_RAW_LOG(FATAL, "thread should not hold mutex %p %s",
1576:   this->Block(waitp.thread);
1733: // the mutex if this thread has blocked, and therefore may be the designated
1766: #ifdef THREAD_SANITIZER
1806: // addition and this thread. So if we would enable race detection here,
1856:     this->Block(waitp.thread);
1906:       waitp->thread->waitp == nullptr || waitp->thread->suppress_fatal_errors,
1923:         this->Block(waitp->thread);
1930:         // This thread tries to become the one and only waiter.
1944:           waitp->thread->waitp = nullptr;
1967:           this->Block(waitp->thread);
1992:         this->Block(waitp->thread);  // wait until removed from list or timeout
1998:         waitp->thread->waitp == nullptr || waitp->thread->suppress_fatal_errors,
2003:       waitp->thread->waitp == nullptr || waitp->thread->suppress_fatal_errors,
2012: // Unlock this mutex, which is held by the current thread.
2013: // If waitp is non-zero, it must be the wait parameters for the current thread
2038:   ABSL_RAW_CHECK(waitp == nullptr || waitp->thread->waitp == nullptr ||
2039:                      waitp->thread->suppress_fatal_errors,
2042:   // the list of waiters.  In addition, it places waitp.thread on the queue of
2223:                // this thread's condition is not known false, AND
2317: // waiting thread may have been moved from the condition variable queue to the
2318: // mutex queue without a wakeup, by Trans().  In that case, when the thread is
2319: // finally woken, the woken thread will believe it has been woken from the
2328: // Used by CondVar implementation to effectively wake thread w from the
2329: // condition variable.  If this mutex is free, we simply wake the thread.
2331: // enqueue thread w on this mutex.
2345:     // conflicting != 0 implies that the waking thread cannot currently take
2357:         // This thread tries to become the one and only waiter.
2389:     ABSL_RAW_LOG(FATAL, "thread should hold write lock on Mutex %p %s",
2399:         FATAL, "thread should hold at least a read lock on Mutex %p %s",
2429: // Remove thread s from the list of waiters on this condition variable.
2442:         while (w->next != s && w->next != h) {  // search for thread
2445:         if (w->next == s) {           // found thread; remove it
2464: // Queue thread waitp->thread on condition variable word cv_word using
2470: // to block this thread.  That would be a problem if the thread were already on
2472: // to tell the unlock code to call CondVarEnqueue() to queue the thread on the
2477:   // This thread might be transferred to the Mutex queue by Fer() when
2482:   // this thread on another queue.
2495:   ABSL_RAW_CHECK(waitp->thread->waitp == nullptr, "waiting when shouldn't be");
2496:   waitp->thread->waitp = waitp;      // prepare ourselves for waiting
2498:   if (h == nullptr) {  // add this thread to waiter list
2499:     waitp->thread->next = waitp->thread;
2501:     waitp->thread->next = h->next;
2502:     h->next = waitp->thread;
2504:   waitp->thread->state.store(PerThreadSynch::kQueued,
2506:   cv_word->store((v & kCvEvent) | reinterpret_cast<intptr_t>(waitp->thread),
2528:   // Mutex, thus queuing this thread on the condition variable.  See
2533:   while (waitp.thread->state.load(std::memory_order_acquire) ==
2535:     if (!Mutex::DecrementSynchSem(mutex, waitp.thread, t)) {
2536:       this->Remove(waitp.thread);
2541:   ABSL_RAW_CHECK(waitp.thread->waitp != nullptr, "not waiting when should be");
2542:   waitp.thread->waitp = nullptr;  // cleanup
2573: // Wake thread w
2579:     // The waiting thread only needs to observe "w->state == kAvailable" to be
2647:         do {                          // for every thread, wake it up
2673: #ifdef THREAD_SANITIZER
24: #include <pthread.h>
61: using absl::base_internal::ThreadIdentity;
424:     // Calling the invariant as is causes problems under ThreadSanitizer.
522:   ThreadIdentity *identity = GetOrCreateCurrentThreadIdentity();
530:   PerThreadSynch *w = Synch_GetPerThread();
538:   PerThreadSynch *s = Synch_GetPerThread();
561:   assert(w == Synch_GetPerThread());
578:   ThreadIdentity *identity = CurrentThreadIdentityIfPresent();
614: static const intptr_t kMuWait        = 0x0004L;  // threads are waiting
619: // designated waker, all threads can avoid taking the slow path in
750: // Return true iff threads x and y are waiting on the same condition for the
773: //       such that all threads in [x, x->skip] have the same condition and
791: // [x, y] inclusive share the same condition.  Sets skip fields of some threads
897: #ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
901:       // pthread_getschedparam() is 5% of the block/wakeup time;
905:       const int err = pthread_getschedparam(pthread_self(), &policy, &param);
907:         ABSL_RAW_LOG(ERROR, "pthread_getschedparam failed: %d", err);
1070:             // in the threads we skipped; none can point to s
2034:   PerThreadSynch *wake_list = kPerThreadSynchNull;   // list of threads to wake
2041:   // This loop finds threads wake_list to wakeup if any, and removes them from
2681:   // ThreadSanitizer does not instrument this file for memory accesses.
59: using absl::base_internal::CurrentThreadIdentityIfPresent;
60: using absl::base_internal::PerThreadSynch;
62: using absl::synchronization_internal::GetOrCreateCurrentThreadIdentity;
67: using absl::synchronization_internal::PerThreadSem;
460: // PerThreadSynch struct points at the most recent SynchWaitParams struct when
510:   reinterpret_cast<PerThreadSynch *>(1);
540:     s->all_locks = LocksHeldAlloc();  // Freed by ReclaimThreadIdentity.
545: // Post on "w"'s associated PerThreadSem.
546: inline void Mutex::IncrementSynchSem(Mutex *mu, PerThreadSynch *w) {
556: // Wait on "w"'s associated PerThreadSem; returns false if timeout expired.
557: bool Mutex::DecrementSynchSem(Mutex *mu, PerThreadSynch *w, KernelTimeout t) {
563:   bool res = PerThreadSem::Wait(t);
590: // PerThreadSem::Wait() for consistency.  Unfortunately, we don't have
648: // PerThreadSynch::readers of the most recently queued waiter, again in the
656: static_assert(PerThreadSynch::kAlignment > kMuLow,
657:               "PerThreadSynch::kAlignment must be greater than kMuLow");
753: static bool MuSameCondition(PerThreadSynch *x, PerThreadSynch *y) {
758: // Given the contents of a mutex word containing a PerThreadSynch pointer,
761:   return reinterpret_cast<PerThreadSynch *>(v & kMuHigh);
818: static PerThreadSynch *Skip(PerThreadSynch *x) {
819:   PerThreadSynch *x0 = nullptr;
820:   PerThreadSynch *x1 = x;
821:   PerThreadSynch *x2 = x->skip;
837: static void FixSkip(PerThreadSynch *ancestor, PerThreadSynch *to_be_removed) {
870: static PerThreadSynch *Enqueue(PerThreadSynch *head,
896:     PerThreadSynch *enqueue_after = nullptr;  // we'll put s after this element
922:         PerThreadSynch *advance_to = head;    // next value of enqueue_after
923:         PerThreadSynch *cur;                  // successor of enqueue_after
985:   s->state.store(PerThreadSynch::kQueued, std::memory_order_relaxed);
993: static PerThreadSynch *Dequeue(PerThreadSynch *head, PerThreadSynch *pw) {
994:   PerThreadSynch *w = pw->next;
1016: static PerThreadSynch *DequeueAllWakeable(PerThreadSynch *head,
1017:                                           PerThreadSynch *pw,
1018:                                           PerThreadSynch **wake_tail) {
1019:   PerThreadSynch *orig_h = head;
1020:   PerThreadSynch *w = pw->next;
1054: void Mutex::TryRemove(PerThreadSynch *s) {