Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4580046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:43:40+00:00 2026-05-21T20:43:40+00:00

I am writing a small program as part of a University course. In this

  • 0

I am writing a small program as part of a University course. In this program, I have a global Boost Mutex which helps me to coordinate two threads.

In my small library, I have to write a cleanup function that, when invoked, literally cleans up after itself.

What I am asking now is: if I create a Mutex, am I supposed to deallocate it as well when I do not need it anymore?

The code I use is simply

boost::mutex mymutex;

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:43:41+00:00Added an answer on May 21, 2026 at 8:43 pm

    Boost mutexes appear to be written to perform all their cleanup in their destructors. If you want to ready that same mutex for resuse, probably you’d want to call .unlock() on it once.

    If you really feel the need to manually get rid of it, I suppose you could make it a pointer and create it with a new. That way you can manually control running of its destructor in your cleanup routine by calling delete on the pointer. However, pointers are kind of error-prone, so using one just so you can show it manually being cleaned up (instead of having it automatically happen when the object goes out of scope at the end of your program) is stoopid. If you get docked a couple of points for not doing that, I’d consider it a small price to pay for designing things right instead.

    If you are really worried about losing points for not manually cleaning up your automatically destructed resources, if I were you I’d go ask my instructor what I need to do. School ain’t free (unlike SO), and such consulting is part of what you are paying them all that money for. Might as well get some value for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was writing this small script the other day.It is a small program which
I am writing a small program in C++ using OpenCV-2.3 API. I have an
I have a problem with Regular Expressions. I'm writing a small program that matches
in small program I'm writing, I have to parse a line of user input.
I am writing a small program to compare two List. If the values are
I'm writing this small program to extract any number of email address from a
I am writing a small program in OpenGL on my Mac. I have a
I'm writing a small program which will make a GET request to a server
I'm writing a small C program in which I call the isnumber() function. #include
I am writing a program that executes two operations on a structure distanceType which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.