boost::log::attributes::current_thread_id — A class of an attribute that always returns the current thread identifier.
// In header: <boost/log/attributes/current_thread_id.hpp> class current_thread_id : public attribute, public attribute_value { public: // types typedef thread::id held_type; // A held attribute value type. // public member functions bool dispatch(type_dispatcher &); shared_ptr< attribute_value > get_value(); shared_ptr< attribute_value > detach_from_thread(); };
Note | |
---|---|
This attribute may be registered globally, it will still return the correct thread identifier no matter which thread emits the log record. |
current_thread_id
public member functionsbool dispatch(type_dispatcher & dispatcher);
The method dispatches the value to the given object.
Parameters: |
|
||
Returns: | true if dispatcher was capable to consume the real attribute value type and false otherwise. |
shared_ptr< attribute_value > get_value();
Returns: | The actual attribute value. It shall not return NULL (exceptions shall be used to indicate errors). |
shared_ptr< attribute_value > detach_from_thread();
The method is called when the attribute value is passed to another thread (e.g. in case of asynchronous logging). The value should ensure it properly owns all thread-specific data.
Returns: | An actual pointer to the attribute value. It may either point to this object or another. In the latter case the returned pointer replaces the pointer used by caller to invoke this method and is considered to be a functional equivalent to the previous pointer. |