diff --git a/headers/private/app/TokenSpace.h b/headers/private/app/TokenSpace.h index c2b2b7afc8..a0dc04b329 100644 --- a/headers/private/app/TokenSpace.h +++ b/headers/private/app/TokenSpace.h @@ -41,6 +41,8 @@ class BTokenSpace : public BLocker { int32 NewToken(int16 type, void* object, new_token_callback callback = NULL); + void SetToken(int32 token, int16 type, void* object); + bool RemoveToken(int32 token, remove_token_callback callback = NULL); bool CheckToken(int32 token, int16 type) const; status_t GetToken(int32 token, int16 type, void** object, diff --git a/src/kits/app/TokenSpace.cpp b/src/kits/app/TokenSpace.cpp index fcf15360a0..332529bb8e 100644 --- a/src/kits/app/TokenSpace.cpp +++ b/src/kits/app/TokenSpace.cpp @@ -52,6 +52,22 @@ BTokenSpace::NewToken(int16 type, void* object, } +/*! + Inserts the specified token into the token space. If that token + already exists, it will be overwritten. + Don't mix NewToken() and this method unless you know what you're + doing. +*/ +void +BTokenSpace::SetToken(int32 token, int16 type, void* object) +{ + BAutolock locker(this); + token_info tokenInfo = { type, object }; + + fTokenMap[token] = tokenInfo; +} + + bool BTokenSpace::RemoveToken(int32 token, remove_token_callback callback) {