OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 class Arena; // defined below | 63 class Arena; // defined below |
64 class Message; // message.h | 64 class Message; // message.h |
65 | 65 |
66 namespace internal { | 66 namespace internal { |
67 class ArenaString; // arenastring.h | 67 class ArenaString; // arenastring.h |
68 class LazyField; // lazy_field.h | 68 class LazyField; // lazy_field.h |
69 | 69 |
70 template<typename Type> | 70 template<typename Type> |
71 class GenericTypeHandler; // repeated_field.h | 71 class GenericTypeHandler; // repeated_field.h |
72 | 72 |
| 73 LIBPROTOBUF_EXPORT extern google::protobuf::internal::SequenceNumber |
| 74 cr_lifecycle_id_generator_; |
| 75 |
73 // Templated cleanup methods. | 76 // Templated cleanup methods. |
74 template<typename T> void arena_destruct_object(void* object) { | 77 template<typename T> void arena_destruct_object(void* object) { |
75 reinterpret_cast<T*>(object)->~T(); | 78 reinterpret_cast<T*>(object)->~T(); |
76 } | 79 } |
77 template<typename T> void arena_delete_object(void* object) { | 80 template<typename T> void arena_delete_object(void* object) { |
78 delete reinterpret_cast<T*>(object); | 81 delete reinterpret_cast<T*>(object); |
79 } | 82 } |
80 inline void arena_free(void* object, size_t /* size */) { | 83 inline void arena_free(void* object, size_t /* size */) { |
81 free(object); | 84 free(object); |
82 } | 85 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 friend class internal::LazyField; // For CreateMaybeMessage. | 548 friend class internal::LazyField; // For CreateMaybeMessage. |
546 | 549 |
547 struct ThreadCache { | 550 struct ThreadCache { |
548 // The ThreadCache is considered valid as long as this matches the | 551 // The ThreadCache is considered valid as long as this matches the |
549 // lifecycle_id of the arena being used. | 552 // lifecycle_id of the arena being used. |
550 int64 last_lifecycle_id_seen; | 553 int64 last_lifecycle_id_seen; |
551 Block* last_block_used_; | 554 Block* last_block_used_; |
552 }; | 555 }; |
553 | 556 |
554 static const size_t kHeaderSize = sizeof(Block); | 557 static const size_t kHeaderSize = sizeof(Block); |
555 static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; | |
556 #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) | 558 #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) |
557 // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom
thread | 559 // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom
thread |
558 // local storage class we implemented. | 560 // local storage class we implemented. |
559 // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. | 561 // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. |
560 static ThreadCache& thread_cache(); | 562 static ThreadCache& thread_cache(); |
561 #elif defined(PROTOBUF_USE_DLLS) | 563 #elif defined(PROTOBUF_USE_DLLS) |
562 // Thread local variables cannot be exposed through DLL interface but we can | 564 // Thread local variables cannot be exposed through DLL interface but we can |
563 // wrap them in static functions. | 565 // wrap them in static functions. |
564 static ThreadCache& thread_cache(); | 566 static ThreadCache& thread_cache(); |
565 #else | 567 #else |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Arena); | 918 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Arena); |
917 }; | 919 }; |
918 | 920 |
919 // Defined above for supporting environments without RTTI. | 921 // Defined above for supporting environments without RTTI. |
920 #undef RTTI_TYPE_ID | 922 #undef RTTI_TYPE_ID |
921 | 923 |
922 } // namespace protobuf | 924 } // namespace protobuf |
923 | 925 |
924 } // namespace google | 926 } // namespace google |
925 #endif // GOOGLE_PROTOBUF_ARENA_H__ | 927 #endif // GOOGLE_PROTOBUF_ARENA_H__ |
OLD | NEW |