Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: src/platform.h

Issue 6070009: Added labelled thread names to help with some debugging activity. Right now,... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/log.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified 380 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified
381 // to ensure that enumeration type has correct value range (see Issue 830 for 381 // to ensure that enumeration type has correct value range (see Issue 830 for
382 // more details). 382 // more details).
383 enum LocalStorageKey { 383 enum LocalStorageKey {
384 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt, 384 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt,
385 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt 385 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt
386 }; 386 };
387 387
388 // Create new thread. 388 // Create new thread.
389 Thread(); 389 Thread();
390 explicit Thread(const char* name);
390 virtual ~Thread(); 391 virtual ~Thread();
391 392
392 // Start new thread by calling the Run() method in the new thread. 393 // Start new thread by calling the Run() method in the new thread.
393 void Start(); 394 void Start();
394 395
395 // Wait until thread terminates. 396 // Wait until thread terminates.
396 void Join(); 397 void Join();
397 398
399 inline const char* name() const {
400 return name_;
401 }
402
398 // Abstract method for run handler. 403 // Abstract method for run handler.
399 virtual void Run() = 0; 404 virtual void Run() = 0;
400 405
401 // Thread-local storage. 406 // Thread-local storage.
402 static LocalStorageKey CreateThreadLocalKey(); 407 static LocalStorageKey CreateThreadLocalKey();
403 static void DeleteThreadLocalKey(LocalStorageKey key); 408 static void DeleteThreadLocalKey(LocalStorageKey key);
404 static void* GetThreadLocal(LocalStorageKey key); 409 static void* GetThreadLocal(LocalStorageKey key);
405 static int GetThreadLocalInt(LocalStorageKey key) { 410 static int GetThreadLocalInt(LocalStorageKey key) {
406 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key))); 411 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key)));
407 } 412 }
408 static void SetThreadLocal(LocalStorageKey key, void* value); 413 static void SetThreadLocal(LocalStorageKey key, void* value);
409 static void SetThreadLocalInt(LocalStorageKey key, int value) { 414 static void SetThreadLocalInt(LocalStorageKey key, int value) {
410 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value))); 415 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
411 } 416 }
412 static bool HasThreadLocal(LocalStorageKey key) { 417 static bool HasThreadLocal(LocalStorageKey key) {
413 return GetThreadLocal(key) != NULL; 418 return GetThreadLocal(key) != NULL;
414 } 419 }
415 420
416 // A hint to the scheduler to let another thread run. 421 // A hint to the scheduler to let another thread run.
417 static void YieldCPU(); 422 static void YieldCPU();
418 423
419 private: 424 private:
425 void set_name(const char *name);
426
420 class PlatformData; 427 class PlatformData;
421 PlatformData* data_; 428 PlatformData* data_;
429
430 // The thread name length is limited to 16 based on Linux's implementation of
431 // prctl().
432 static const int kMaxThreadNameLength = 16;
433 char name_[kMaxThreadNameLength];
434
422 DISALLOW_COPY_AND_ASSIGN(Thread); 435 DISALLOW_COPY_AND_ASSIGN(Thread);
423 }; 436 };
424 437
425 438
426 // ---------------------------------------------------------------------------- 439 // ----------------------------------------------------------------------------
427 // Mutex 440 // Mutex
428 // 441 //
429 // Mutexes are used for serializing access to non-reentrant sections of code. 442 // Mutexes are used for serializing access to non-reentrant sections of code.
430 // The implementations of mutex should allow for nested/recursive locking. 443 // The implementations of mutex should allow for nested/recursive locking.
431 444
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 PlatformData* data_; // Platform specific data. 624 PlatformData* data_; // Platform specific data.
612 int samples_taken_; // Counts stack samples taken. 625 int samples_taken_; // Counts stack samples taken.
613 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 626 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
614 }; 627 };
615 628
616 #endif // ENABLE_LOGGING_AND_PROFILING 629 #endif // ENABLE_LOGGING_AND_PROFILING
617 630
618 } } // namespace v8::internal 631 } } // namespace v8::internal
619 632
620 #endif // V8_PLATFORM_H_ 633 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698